Game Development Community

Help creating a subclass of GameBaseData

by Johnathan Moore · in Torque Game Engine · 03/19/2006 (12:04 pm) · 6 replies

Does anyone know the solution to this error, the title explains what im trying to do

c:\enginemake\engine\console/consoleObject.h(330) : error C2243: 'type cast' : conversion from 'RTSSquadData *' to 'ConsoleObject *' exists, but is inaccessible
        c:\enginemake\engine\console/consoleObject.h(330) : while compiling class template member function 'ConsoleObject *ConcreteClassRep<T>::create(void) const'
        with
        [
            T=RTSSquadData
        ]
        c:\enginemake\engine\game/RTS/RTSSquad.h(27) : see reference to class template instantiation 'ConcreteClassRep<T>' being compiled
        with
        [
            T=RTSSquadData
        ]

If someone would like me to send them the source please tell

any help?

#1
03/19/2006 (12:34 pm)
Thats because something is protected or private.
#2
03/19/2006 (12:38 pm)
Certain things arre in private and protected are they not supposed to be

class RTSSquadData : GameBaseData
{
   // This typedef is required for tie ins with the script language.
   //--------------------------------------------------------------------------
	protected:
      typedef GameBaseData Parent;
   //--------------------------------------------------------------------------

	  // This macro ties us into the script engine, and MUST MUST MUST be declared
   // in a public section of the class definition.  If it isn't you WILL get
   // errors that will confuse you.
   //--------------------------------------------------------------------------
   public:
   DECLARE_CONOBJECT(RTSSquadData);
   //--------------------------------------------------------------------------

	  // Constructer Declaration
	  RTSSquadData::RTSSquadData();
	  // Destructer Declaration
      RTSSquadData::~RTSSquadData();

      // These are overloaded functions from SimObject that we handle for
      // tie in to the script language.
      //-----------------------------------------------------------------------
	  static void consoleInit();
	  bool onAdd();
      void onRemove();
      static void initPersistFields();
	  void packData(BitStream* stream);
      void unpackData(BitStream* stream);
	  virtual bool preload(bool server, char errorBuffer[256]);

	private:
    U32 mMemberVar;      
	U32 herohandle;
	U32 leaderhandle;

};
#3
03/19/2006 (12:44 pm)
It is not to do with my class doesnt make any difference if the whole class is public
#4
03/19/2006 (1:07 pm)
Try changing this
class RTSSquadData : GameBaseData

to this
class RTSSquadData : public GameBaseData
#5
03/19/2006 (1:12 pm)
Hey thanks all the same but I think ive just this second cracked it, well it compiles. I changed class to struct so it reads

struct RTSSquadData : GameBaseData

I have no idea what the difference is I just stumbled on it seeing RTSCamera declared using it
I will now try it in script
#6
03/19/2006 (1:26 pm)
It works!!! It was obviously trying to convert the class to struct not that I know the difference, thanks for the help

[Edit]
I see where you where coming from Orion
the difference between struct and class

"Struct and class are the same thing with one difference
struct has public members as default
class has private members as default."