Hi there,
I have a problem with two dimensional arrays :( I feel very stupid and Visual C does not help me :( and I also think that my mistake is very stupid but still I can't find it :( I have this code:
double matrix[100][100]; //which is full with a matrix 3x4
double nVector[10000]; // for negative doubles
//I wanted to see if there...
I've got an application that's using a static library I made. One .cpp file in the library has a static variable declaration, whose ctor calls a function on a singleton that does something- e.g. adds a string.
Now when I use that library from the application, my singleton doesn't seem to contain any traces of the string that was suppos...
How can I split a string with Boost with a regex AND have the delimiter included in the result list?
for example, if I have the string "1d2" and my regex is "[a-z]" I want the results in a vector with (1, d, 2)
I have:
std::string expression = "1d2";
boost::regex re("[a-z]");
boost::sregex_token_iterator i (expression.begin (),
...
If I've registered my very own vectored exception handler (VEH) and a StackOverflow exception had occurred in my process, when I'll reach to the VEH, will I'll be able to allocate more memory on the stack? will the allocation cause me to override some other memory? what will happen?
I know that in .Net this is why the entire stack is com...
How can I print only the current time (not the date) to a file? I need it in this format...
13:55:36
I've tried a few different ideas but they all include the date too.
...
Okay, sample code first; this is my attempt at communicating what it is that I'm trying to do, although it doesn't compile:
#include <iostream>
template <class T>
class Base
{
public:
virtual void my_callback() = 0;
};
class Derived1
: public Base<int>
, public Base<float>
{
public:
void my_callback<int>()
{
cout << "Int callba...
Here's a curiosity I've been investigating. The .NET Dictionary class performs ridiculously fast compared to the STL unordered_map in a test I keep running, and I can't figure out why.
(0.5 seconds vs. 4 seconds on my machine)
(.NET 3.5 SP1 vs. Visual Studio 2008 Express SP1's STL)
On the other hand, if I implement my own hash table i...
Is there any sort of performance difference between the arithmetic operators in c++, or do they all run equally fast? E.g. is "++" faster than "+=1"? What about "+=10000"? Does it make a significant difference if the numbers are floats instead of integers? Does "*" take appreciably longer than "+"?
I tried performing 1 billion each of "...
I have a subset of a pointer class that look like:
template <typename T>
struct Pointer
{
Pointer();
Pointer(T *const x);
Pointer(const Pointer &x);
template <typename t>
Pointer(const Pointer<t> &x);
operator T *() const;
};
The goal of the last constructor is to allow to pass a Pointer of a subclass, o...
I am looking to use the map file to resolve addresses that I get from the exe. Is there a library for parsing it or a more easier to parse format?
...
I have read that there is some overhead to using C++ exceptions for exception handling as opposed to, say, checking return values. I'm only talking about overhead that is incurred when no exception is thrown. I'm also assuming that you would need to implement the code that actually checks the return value and does the appropriate thing, ...
I have a STL::multimap and I search to populate a std::list with value which key is duplicated.
Can I find/insert to a std::list the value of elements for all key where count > 1 without counting them one by one?
std::multimap<int, std::string> mm ;
mm[0] = "a" ;
mm[1] = "b" ;
mm[0] = "c" ;
mm[2] = "j" ;
mm[2] = "k" ;
std::list<std...
Hi all. I'm getting data from a binary file, reading from file and writing in a vector of unsigned char. I can't edit it, because I'm using a external library.
But the data that I'm reading from file is a 16 bits image, and I'd like to put the data in a vector of unsigned short
Maybe I can do a cast for it?
Rgds.
...
Is there any way to declare these classes in a header file without indirection?
// Forwards declaration of B
class B;
class A
{
public:
// Default parameter referring to B. May return its parameter
const B& func(const B& b = B());
};
class B
{
public:
// B ctors
B() {}
B(const B&) {}
// B has A as a member
...
As a C++ programmer becoming more familiar with Java, it's a little odd to me to see language level support for locking on arbitrary objects without any kind of declaration that the object supports such locking. Creating mutexes for every object seems like a heavy cost to be automatically opted into. Besides memory usage, mutexes are an ...
What is the difference between pointer to a reference, reference to a pointer and pointer to a pointer in C++?
Where should one be preferred over the other?
...
I have a class of interest (call it X).
I have a std::list<X*> (call it L).
I have a function (call it F).
F(L) returns a subset of L (a std::list<X*>) according to an algorithm that examines the internal state of each X in the list.
I'm adding to my application a std::map<int,X*> (call it M), and I need to define F(M) to operate in ...
I have compiled FreeImage from source and installed it.
When I run sudo make install in installs the following files on my system
/usr/local/include/FreeImage.h
/usr/local/lib/libfreeimage-3.10.0.dylib
/usr/local/lib/libfreeimage.a
However in my C++ program it says error file not found when I do this:
#include <FreeImage.h>
I have...
I am looking for a syntax to allocate memory from a secondary memory device and not from the default heap.
How can i implement it? Using malloc() would by default take it from heap... Surely there must be another way!
...
I am learning the boost::lambda library and for that I wrote this sample code to convert an vector<A> into vector<int> by extracting the value from A object.
class A
{
public:
A(int n) : m_n(n){}
int get() const {return m_n;}
private:
int m_n;
};
int _tmain(int argc, _TCHAR* argv[])
{
using namespace boost::lambda;
...