Saving structures

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
timofimo
Posts: 7
Joined: November 27th, 2012, 9:02 pm

Saving structures

Post by timofimo » April 8th, 2013, 6:26 am

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.

User avatar
Nosferatu
Posts: 36
Joined: July 25th, 2012, 7:08 am
Location: Slovakia

Re: Saving structures

Post by Nosferatu » April 8th, 2013, 9:07 pm

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.

Musi
Posts: 106
Joined: November 25th, 2012, 1:06 am

Re: Saving structures

Post by Musi » April 9th, 2013, 3:48 pm

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.

User avatar
Xanderxavier
Posts: 9
Joined: July 27th, 2012, 5:32 pm

Re: Saving structures

Post by Xanderxavier » April 11th, 2013, 12:32 pm

http://www.cplusplus.com/doc/tutorial/structures/, yes you can use struct members like any other variable

Post Reply