I'm a Java programer trying to complete a project in c++.
I want to create a vector as a member of a class.
Code:
class SpriteManager{
vector<Sprite*> spriteList;
};
Why won't this work? It will not compile if I try to use "spriteList" in my class's scope. I've tried having a pointer to a vector and using the "new" operator, but the code gets ugly with all the indirections.
Also, I've noticed that tutorials always show how to make an object this way.
Code:
ObjectType myObject;
Then they mention that you can have a pointer to an object. I'm used to having pointers to objects but why would the language allow an object to reside on the stack? Is there an advantage?