Proper initialization for a derived abstract class

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
igorfk
Posts: 15
Joined: Sat Mar 08, 2008 10:39 pm

Proper initialization for a derived abstract class

Post by igorfk »

Hi people,

How do I derive and then initializate an abstract class?

I have this header file

Code: Select all

//classCTrack.h

class CTrack
{
  public:
    CTrack();
    virtual ~CTrack();
    void set_Track(stringc trackName,ISceneManager* levelMgr,IPhysicsManager* plevelMgr);
  private:
    IPhysicsNode* ptrackNode; //want to derive and initialize IPhyscsNode that is abstract, but how?
    stringc meshName;
};
#endif
And this cpp file

Code: Select all

//classCTrack.cpp

CTrack::CTrack()
{
  meshName=NULL;
}
CTrack::~CTrack()
{
}
void CTrack::set_Track(stringc trackName,ISceneManager* levelMgr,IPhysicsManager* plevelMgr)
{
  meshName=(trackName+".ms3d");
  levelMgr->addMeshSceneNode(levelMgr->getMesh(meshName.c_str()),0,1);

  ptrackNode = plevelMgr->addPhysicsLevelNode(levelMgr->getSceneNodeFromId(1,0),levelMgr->getMesh(meshName.c_str()));
//here the ptrackNode does not receive any value (the msvc debugger tells me that), since its abstract, I think.
}
In fact, my objective is that ptrackNode can receive values in the classCTrack.cpp file.

I'd tried to search but I think that my question is the noobiest ever :) and the various topics subject names are too much generic like "help", "question", "problem here", "???"...
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I do not think those words mean what you think they mean.

IPhysicsNode would appear to be an interface class; if so, then it's supposed to be abstract. What addPhysicsLevelNode() will actually return is an instance of a concrete class derived from IPhysicsNode.

If addPhysicsLevelNode() is returning 0, then it's most likely because you're passing it garbage. What makes you confident that levelMgr->getSceneNodeFromId(1,0) is returning a scene node pointer rather than 0?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply