Having inheritance problem

Hi, I have 3 classes. Parent class is Sprite.
It goes like this:
1
2
3
4
class Sprite
{
...
}

1
2
3
4
class WorldOBJ: public Sprite
{
...
}

1
2
3
4
class Player: public WorldOBJ
{
...
}


The problem is, I cannot access methods that are in Sprite class from either other class. I have #include "Sprite.h" in WorldOBJ and #include "WorldOBJ.h" in Player class.

So, What I mean is, in my main.cpp, I create a Player like so:
Player g_player;
I then try to call a Sprite function like so:
g_player.setSprite("blah.png");

I get the following error:
main.cpp|25|error: expected constructor, destructor, or type conversion before ‘.’ token|

Is it possible to have 3 levels of inheritance like I have? What am I doing wrong?
Is it possible to have 3 levels of inheritance like I have?

It's possible to have any level of inheritance.

Do you actually include the header for your player in your main.cpp?
Yes I do. I am not sure what other info I would need to give.

Even in the WorldOBJ class, I cannot access the Sprite methods. But I can access all WorldOBJ methods from the Player
Last edited on
Are the methods of sprite public? Sounds like they might be private.
main.cpp|25|error: expected constructor, destructor, or type conversion before ‘.’ token|


This sounds to me like 'g_player' isn't what you expect.

Can you post the actual code that's generating this error?

Maybe if we see more context the problem will be easier to spot.

I'm betting the problem is with how g_player is declared.
It was an IDE bug. I just restarted it and it works.
Topic archived. No new replies allowed.