Class Question...
Okay, so I'm making a sprite class, and I am using SFML to do it. My question is what's the difference between doing:
class Sprite : public sf::Sprite
versus:
1 2 3 4 5
|
class Sprite
{
private:
sf::Sprite Foo;
};
|
And is there a clear benefit to doing one over the other? Thank you for any help you can give!
- Kyle
Last edited on
And is there a clear benefit to doing one over the other? |
Yes.
This
class Sprite : public sf::Sprite
is used if you want to extend
sf::Sprite
i.e. overriding virtual functions
if not you might prefer this
1 2 3 4 5
|
class Sprite
{
private:
sf::Sprite Foo;
};
|
if you just want to use
sf::Sprite
. The benefit would be that
Sprite
is free to inherit from other classes
Thank you a lot!
- Kyle
Topic archived. No new replies allowed.