Class member overloading..?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dwfait
Posts: 28
Joined: Sun Sep 24, 2006 8:13 pm

Class member overloading..?

Post by dwfait »

Hi..I'm wondering if you can do something like this:

Code: Select all

class a
{
     public:
          ISceneNode* Node;
}


class b : public a
{
      public:
            ICameraSceneNode* Node;
}



I have code like that to similar effect in my project, and it compiles fine, but whenever a function is called that addressed the ICameraSceneNode Node, the program "encounters an unexpected error and has to close".

If it's not possible, can anyone give any suggestions to workarounds?
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

You could do the following:

Code: Select all

class a
{
    public:
        a(ISceneNode* Node)
        {
            m_Node = Node;
        }
        ISceneNode* m_Node;
};

class b : public a
{
    public:
        b(ICameraSceneNode* cam) : a(cam)
        {
            m_cam = cam;
        }
        ICameraSceneNode* m_cam;
};
That way u can use the scenenode like a scenenode out of the base class and the camera from the otherone.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The error is due to the elements being pointers which you have to set to pointing to existing objects. Otherwise each access will crash your app.
Post Reply