I need some clarification on C++ memory allocation, I'll just get right to an example
Let's say I have made a class A, which contains two containers: a hash_map and a std::vector like this:
class Example{
// methods to add stuff to containers
//...
std::hash_map<std::string,int> map;
std::vector<std::string> vec;
}
If I then create an object of example on the heap using the new operator:
Example* ex = new Example();
and add a thousand entries to each container, will the entries I add be located on the heap as well? If yes, then what would be different if I did:
class Example{
// methods to add stuff to containers
//...
std::hash_map<std::string,int>* map;
std::vector<std::string>* vec;
}
and then Example* ex = new Example();