this is my class
class game
{
private:
vector<stack> stacks_;
public:
game();
void solve();
friend ostream& operator<<(ostream& os,const game& game);
};
this is the constructor.
game::game()
{
for (int i = 0; i < 3; i++)
{
stack s;
stacks_.push_back(s);
}
cube blueCube(4,0);
stacks_[0].push(blueCube);
cube yellowCube(3,1);
stacks_[0].push(yellowCube);
cube redCube(2,2);
stacks_[0].push(redCube);
cube blackCube(1,2);
stacks_[0].push(blackCube);
}
in the main function
int main()
{
game g;
cout<<g<<endl;
}
after creating the game class why the vector in the game class still have the object.
I thought all objects that are declared like that cube blueCube(4,0);
without new are on the stack and when I leave the constructor all of them will be deleted.
Can anyone explain please ?