Trying to wrap up some code, having problems!

This is a discussion on Trying to wrap up some code, having problems! within the C++ Programming forums, part of the General Programming Boards category; Hello. I'm trying to wrap up some code for a map editor SDK I'm using, I havn't got it confirmed ...

  1. #1
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717

    Trying to wrap up some code, having problems!

    Hello.

    I'm trying to wrap up some code for a map editor SDK I'm using, I havn't got it confirmed that this is useful, but still I thought I'd make it for the experience and if it's useful
    Anyways, I'm using a template and I'm not used to templates yet :S still I found no other way to do it...
    I've also been trying unlimited different ways to do this, this is what I'm currently at...
    Code:
    template<typename A_Type> class CEntity : hgeEntity {
    private:
    	
    	hgeEntityLayers layer;
    	bool m_static;
    	A_Type m_class;
    
    public:
    	CEntity(const hgeEntityLayers layer_, bool static_, CEntity class_) : hgeEntity(layer_, static_) { layer = layer_; m_static = static_; m_class = class_; }
    	CEntity* Spawn() { return new CEntity(layer, m_static,m_class); }
    
    	virtual void Initialize(){}
    };
    And the error:
    Code:
     error C2955: 'CEntity' : use of class template requires template argument list
    And this is where I try to call the constructor...
    Code:
    CCharacter::CCharacter(hgeResourceManager resource_): CEntity(HEL_MIDDLE2, false, CCharacter(resource_))
    Thanks in advance!
    Currently research OpenGL

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,266
    Your CEntity class constructor accepts, as third argument, a Centity<A_object> object by value.

    The CCharacter constructor attempts to pass a newly created CCharacter(resource) as if it is a CEntity. The first problem is that is infinitely recursive (the CCharacter constructor attempts to invoke itself in its own initialiser list).

    The second obvious problem, and the cause of the error message, is probably that the CEntity needs to be constructed as a CEntity<something> - it is a template class, after all.

    The information you've provided is woefully incomplete (my guess, from the manner you've asked your question, is you're just hacking rather than thinking things through) so not much more help is possible.

  3. #3
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Yeah, I guessed it would be recursive... I think I'll just skip the wrapper xP but thanks anyways!
    Currently research OpenGL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with GetDiskFreeSpaceEx/my code...
    By scrappy in forum Windows Programming
    Replies: 1
    Last Post: 07-30-2003, 11:16 AM
  2. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 11:51 AM
  3. structs, array, code has problems, Im lost
    By rake in forum C++ Programming
    Replies: 4
    Last Post: 03-13-2002, 01:02 AM
  4. problems with output from code
    By simhap in forum C++ Programming
    Replies: 0
    Last Post: 10-08-2001, 12:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21