Jump to content
  • Advertisement

Archived

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

billybob

inheritence?

This topic is 5814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
OOOOOH thats what that is. i''ve been looking at a lot of tutorials, and i could never figure out what that was. thx

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!