Archived

This topic is now archived and is closed to further replies.

billybob

inheritence?

Recommended Posts

how do i use it? for my base object, every pickup/player/gun/bullet has the same class, Object. but then things like player need more variables, so if i understand inheritance correctly, i can still make player an object, but add variables somehow. is this inheriatnce? and hwo do i do it.

Share this post


Link to post
Share on other sites
Well, how inheritance works is that you create a base class, and then for every type of object you create. You would create another class, but state that it is deriving from the first class, for example, lets say that you have a base class foo, and you want to create a class that takes all of the attributes of base class, but would add other features as well.

class foo{
blah;
blah;
blah;
};
class bar: public foo{
//more stuff goes here
};

I hope that this will help you, and good luck with your project.

Share this post


Link to post
Share on other sites