[Solved] Display a map of two vectors

There could be gundreds of way to do that. Here is one: template<class T> void dumpVector( const std::vector<T>& vect ) { for ( std::vector<T>::const_iterator iter = vect.begin(); iter != vect.end(); ++iter ) { std::cout << ” ” << *iter; } } for ( std::map<vector<double>,vector<int>>::const_iterator mapIter = path.begin(); mapIter != path.end(); ++mapIter ) { std::cout << … Read more

[Solved] Generic class with type as pointer to object of another class – NOT WORKING [closed]

Your code should compile if you: choose one of class/struct in types and one of class/typename in template parameters use semicolons after class or struct definitions write > > instead of >> in nested templates (pre C++11) 5 solved Generic class with type as pointer to object of another class – NOT WORKING [closed]

[Solved] Changing vector in function by pointer

The function does not make sense. For starters it is unclear why you are using a pointer to the vector instead of a reference to the vector. Nevertheles, this declaration vector<unsigned char> vec(5); does not reseeve a memory for the vector. It initializes the vector with 5 zero-characters which will be appended with other characters … Read more

[Solved] Size of C++ vector is invalid

From your non-understable question, I can guess that you want the vector to treat the [] operator as “edit if it is exist or create if it is not”. Some thing like the behavior of [] operator in std::map for example.. You simply can not. It was not designed like this. BTW, you may do … Read more

[Solved] C++ Issues with vector

You did not show the code which adds the Child*s to the vector, but the symptoms you describe provide compelling evidence that you used pointers to some kind of local or temporary objects, which go out of scope (are destroyed) while the vector still holds the pointers. Your program hangs as a result of using … Read more