Is there a way to save the data saved in a structure for multiple frames?
Like how you do when you declare an int in Game.h ,then set the starting value in Game.cpp and then intname++;. I want to use it to move a character across the screen.
Saving structures
Re: Saving structures
Not sure what do you mean, but if you are looking for an alternative to declaring it as a member variable in class then you can just declare it wherever in the code, just put "static" before the type and the variable will persist even if the program gets out of scope of that variable.
Re: Saving structures
You can do the same with a structure object, declare it as a member of the Game class. The only thing is I don't think you can initialize a structure in the initializer list, has to be in the function body.
Musi
There are 10 types of people that understand binary.
Those that do, and those that don't.
There are 10 types of people that understand binary.
Those that do, and those that don't.
- Xanderxavier
- Posts: 9
- Joined: July 27th, 2012, 5:32 pm
Re: Saving structures
http://www.cplusplus.com/doc/tutorial/structures/, yes you can use struct members like any other variable