About Store Forum Documentation Contact
Donations:
225$/mo



Post Reply 
Cannot instantiate abstract class
Author Message
Ogniok Offline
Member

Post: #1
Cannot instantiate abstract class
Hi!

I have "SpecialPoint" class i my game based on Game::Obj. When compiling I got this error:

Code:
error C2259: 'SpecialPoint' : cannot instantiate abstract class
1>        due to following members:
1>        'void EE::Game::Obj::pos(const EE::Vec &)' : is abstract
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\game\object.h(22) : see declaration of 'EE::Game::Obj::pos'
1>        'EE::Vec EE::Game::Obj::pos(void)' : is abstract
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\game\object.h(21) : see declaration of 'EE::Game::Obj::pos'
1>        'void EE::Game::Obj::matrix(const EE::Matrix &)' : is abstract
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\game\object.h(24) : see declaration of 'EE::Game::Obj::matrix'
1>        'EE::Matrix EE::Game::Obj::matrix(void)' : is abstract
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\game\object.h(23) : see declaration of 'EE::Game::Obj::matrix'
1>        'Bool EE::Game::Obj::update(void)' : is abstract
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\game\object.h(47) : see declaration of 'EE::Game::Obj::update'
1>        'UInt EE::Game::Obj::drawPrepare(void)' : is abstract
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\game\object.h(50) : see declaration of 'EE::Game::Obj::drawPrepare'
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\misc\misc.h(144) : while compiling class template member function 'void EE::ClassFunc<TYPE>::New(Ptr)'
1>        with
1>        [
1>            TYPE=SpecialPoint
1>        ]
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\misc\memory containers.h(272) : see reference to class template instantiation 'EE::ClassFunc<TYPE>' being compiled
1>        with
1>        [
1>            TYPE=SpecialPoint
1>        ]
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\misc\memory containers.h(272) : while compiling class template member function 'EE::Memx<TYPE>::Memx(Int)'
1>        with
1>        [
1>            TYPE=SpecialPoint
1>        ]
1>        c:\program files\microsoft visual studio 9.0\vc\include\esenthelengine\game\world.h(16) : see reference to class template instantiation 'EE::Memx<TYPE>' being compiled
1>        with
1>        [
1>            TYPE=SpecialPoint
1>        ]
1>        d:\rts\source\game.h(11) : see reference to class template instantiation 'EE::Game::ObjMemx<TYPE>' being compiled
1>        with
1>        [
1>            TYPE=SpecialPoint
1>        ]

This is my code:

SpecialPoint.h
Code:
/******************************************************************************/
struct SpecialPoint : Game::Obj
{
   Str pointID;

   virtual void create(Game::ObjParams &obj);

   SpecialPoint();
};
/******************************************************************************/

SpecialPoint.cpp
Code:
/******************************************************************************/
#include "stdafx.h"
#include "Main.h"
/******************************************************************************/
SpecialPoint::SpecialPoint()
{
    pointID = "";
}
void SpecialPoint::create(Game::ObjParams &obj)
{
    __super::create(obj);

   //Detect parameters
   if(Param *p = obj.findParam("pointID")) pointID = p->asStr();
}
/******************************************************************************/

What's the reason? How I can repair it?
(This post was last modified: 11-13-2010 08:18 PM by Ogniok.)
11-13-2010 08:02 PM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #2
RE: Cannot instantiate abstract class
I'll look into it if i can
(This post was last modified: 11-13-2010 08:22 PM by Dandruff.)
11-13-2010 08:10 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #3
RE: Cannot instantiate abstract class
If you get only a linking problem then the code is fine without any errors. Only problem looks like it that you don't have a pointer extern to its class/struct. Or use forward declaration but i wouldn't use that cause its not very clean.

There is always evil somewhere, you just have to look for it properly.
11-13-2010 08:24 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #4
RE: Cannot instantiate abstract class
I think i found it, but it may not be what you were looking for

Code:
struct SpecialPoint : Game::ObjParams
{
   Str pointID;

   virtual void create (Game::ObjParams &obj);

   SpecialPoint();
};

I'm not sure if it works or not as i did not run it but it built without errors. Good luck!
(This post was last modified: 11-13-2010 08:49 PM by Dandruff.)
11-13-2010 08:44 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #5
RE: Cannot instantiate abstract class
(11-13-2010 08:44 PM)Dandruff Wrote:  I think i found it, but it may not be what you were looking for

Code:
struct SpecialPoint : Game::ObjParams
{
   Str pointID;

   virtual void create (Game::ObjParams &obj);

   SpecialPoint();
};

I'm not sure if it works or not as i did not run it but it built without errors. Good luck!

Obviously that wont work at all... cause ObjParams isn't a item/obj class to abstract from.

There is always evil somewhere, you just have to look for it properly.
(This post was last modified: 11-13-2010 08:53 PM by Dynad.)
11-13-2010 08:52 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #6
RE: Cannot instantiate abstract class
lol, knew something was amidst..

But its ok! Dandruff will try again...
11-13-2010 09:03 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #7
RE: Cannot instantiate abstract class
Did you look at "EsenthelEngineSDK\Tutorials\Source\Advanced\4 - Demos, Game Basics\Game Basics\09 - Extending Game Object Class" tutorial? You're missing required methods.
11-13-2010 09:26 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #8
RE: Cannot instantiate abstract class
(11-13-2010 09:26 PM)Driklyn Wrote:  Did you look at "EsenthelEngineSDK\Tutorials\Source\Advanced\4 - Demos, Game Basics\Game Basics\09 - Extending Game Object Class" tutorial? You're missing required methods.

Yeah, if you create new class based on Game::Obj you have to create: create, 2 pos, 2 matrix, update and drawPreparew functions wink
11-13-2010 10:18 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #9
RE: Cannot instantiate abstract class
Yeah. I have forgotten. Now it works, thanks.
11-13-2010 10:30 PM
Find all posts by this user Quote this message in a reply
Post Reply