Skip to main content
GameDev.net gamedev.net
🔒 Locked

Clearing classes

Started by MetaKnight Jul 22, 2002 at 8:37 PM 4 replies 200+ views
Original Post
MetaKnight
MetaKnight
I have 4 classes for computer racers in a race game i have. but i need to reset them back to normal for the next track. how do i do that? please help
Cahaan
Cahaan
Just make a cleanup() function in your class that initialize all member variables to 0, NULL, "", and so on...
Darkhaven Beta-test stage coming soon.
EvilCrap
EvilCrap
you could use a reset/cleanup function, or a better solution might be to have an instance called "empty" or something, which has all default properties set. you would then use the default copy to set your other classes to "empty". this is a neat idea because u can have different default, const classes.


  
class CRacer{
public:
int _x;
int _y;
int _z;
CRacer(int x, int y, int z){
_x = x;
_y = y;
_z = z;
}
};

void main()
{
const CRacer defRacer1(5,5,5);
const CRacer defRacer2(10,10,10);
CRacer player1(defRacer1);
player1 = defRacer2;
}
Arild Fines
Arild Fines
quote:
Original post by EvilCrap
void main()


Shame on you.




"The churches used to win their arguments against atheism, agnosticism, and other burning issues by burning the ismists, which is fine proof that there is a devil but hardly evidence that there is a God."
Ben Lindsey and Wainwright Evans
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
EvilCrap
EvilCrap
Arild Fines i feel like calling u a really large "f"ing moron, but i wont, since im not n a trolling mood.
EvilCrap
EvilCrap
does this help you out arid? im sure its really relative to metyaknights problems.


int main(int argc char**argv)
{
//no need for source as that would be completely off topic
return 0;
}


[edited by - evilcrap on July 23, 2002 10:37:34 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.