My aim is to create a vector containing many pre-prepared (I dont have the two data members until later on but I want to allocate as much as I can in continuous memory) instances of my object in continuous memory and then later on in my program I can quickly use one of these prepared "shells" to instantiate my object quicker. Most importantly all of these objects will be located in the same continuous memory addresses.
To achieve the above I did this:
vector<MyClass*>* v = new vector<MyClass>();
v.reserve(10000);
//Later on....
// I want to create my object in the continuous memory I "reserved"
// and have a variable name to it:
v->push_back(MyClass m(10,20));
process(m);
But I cannot get it to compile whilst still having a variable name on the object.... here is MyClass:
class MyClass{
public:
MyClass();
MyClass(int a, int b);
MyClass(const MyClass& m);
int a;
int b;
private:
//Made above example simpler by putting everything public
}