Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > referencing

Reply
Thread Tools

referencing

 
 
Michael Sgier
Guest
Posts: n/a
 
      09-11-2005
Hello
in my header file i've:
class CSimpEngine : public CEngine
{

CSimpEngine()
{
....
}

i get here the error: undefined reference to `vtable for CSimpEngine'
and in my class CEngine i've:

class CEngine
{
public:
CEngine() {}
~CEngine() {}
};
What am i doing wrong? What is vtable?
THANKS and regards
Michael
 
Reply With Quote
 
 
 
 
John Carson
Guest
Posts: n/a
 
      09-11-2005
"Michael Sgier" <> wrote in message
news:4323f080$0$1146$
> Hello
> in my header file i've:
> class CSimpEngine : public CEngine
> {
>
> CSimpEngine()
> {
> ...
> }
>
> i get here the error: undefined reference to `vtable for CSimpEngine'
> and in my class CEngine i've:
>
> class CEngine
> {
> public:
> CEngine() {}
> ~CEngine() {}
> };
> What am i doing wrong? What is vtable?
> THANKS and regards
> Michael


You won't get that error from the code you have shown. Show us real code
that exhibits the problem.

--
John Carson

 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      09-11-2005
Michael Sgier wrote:
> Hello
> in my header file i've:
> class CSimpEngine : public CEngine
> {
>
> CSimpEngine()
> {
> ...
> }
>
> i get here the error: undefined reference to `vtable for CSimpEngine'
> and in my class CEngine i've:
>
> class CEngine
> {
> public:
> CEngine() {}
> ~CEngine() {}
> };
> What am i doing wrong? What is vtable?
> THANKS and regards
> Michael


That error usually happens because you declared a virtual function but
forgot to define it.

But there are no virtual functions in the code you posted. If you want
help with code it always helps to post the actual code, instead of the
pieces of the code that you think might be relevant.

Of course this doesn't mean that you should post pages and pages of
code. Instead when you have an error you don't understand, spend some
time to create the smallest possible program that still has the error
you don't understand, then post the whole program. Not only will this be
a good learning exercise for you it also ensures that you will get your
questions answered promptly and accurately.

john
 
Reply With Quote
 
Michael Sgier
Guest
Posts: n/a
 
      09-11-2005
Hello again
in Main.cpp i've:
CSimpEngine* MyCSimpEngine = new CSimpEngine;

and i've added in simpengine.cpp this:
CSimpEngine::CSimpEngine()
{
gameCamera = new CCamera;
}

CSimpEngine::~CSimpEngine()
{
delete gameCamera;
gameCamera = NULL;
}

do i need to do that? I have the declaration in simpengine.h as in my
previous mail.
and i still get the same error:
main.o(.gnu.linkonce.t._ZN11CSimpEngineC1Ev+0x1b): In function
`CSimpEngine::CSimpEngine[in-charge]()':
/home/michael/Desktop/div.OpenGL/agentin_laura/src/simpengine.h:32:
undefined reference to `vtable for CSimpEngine'
THANKS Michael
 
Reply With Quote
 
Michael Sgier
Guest
Posts: n/a
 
      09-11-2005
Maybe like this it's clearer. My simpengine.h:

class CSimpEngine : public CEngine
{
public:
CSimpEngine()
{
gameCamera = new CCamera;
}

~CSimpEngine()
{
delete gameCamera;
gameCamera = NULL;
}
};
 
Reply With Quote
 
John Carson
Guest
Posts: n/a
 
      09-11-2005
"Michael Sgier" <> wrote in message
news:43240839$0$1164$
> Maybe like this it's clearer. My simpengine.h:
>
> class CSimpEngine : public CEngine
> {
> public:
> CSimpEngine()
> {
> gameCamera = new CCamera;
> }
>
> ~CSimpEngine()
> {
> delete gameCamera;
> gameCamera = NULL;
> }
> };


This is completely useless. Read what John Harrison wrote.

1. Simplify the code as far as you can while still getting the error.
2. Then supply us with the EXACT and COMPLETE code from 1. that you run
through the compiler.

Since you appear to have some psychological resistance to doing what is
necessary, let me make two points.

First, you don't know what the problem is otherwise you wouldn't be posting
here. That means that you don't know where in your code the problem is and
hence your attempts to select relevant code are very likely to fail.

Second, your attempts to select relevant code have in fact failed. Consider
the following code, which consists of everything you have posted, plus a few
other details that I have filled in. It compiles without any errors. Thus
the problem is not in the code you have posted. Don't waste any more time
supplying selected excerpts.

#include <cstdlib>

class CEngine
{
public:
CEngine() {}
~CEngine() {}
};

class CCamera
{};

class CSimpEngine : public CEngine
{
public:
CSimpEngine()
{
gameCamera = new CCamera;
}

~CSimpEngine()
{
delete gameCamera;
gameCamera = NULL;
}
private:
CCamera *gameCamera;
};

int main()
{
CSimpEngine* MyCSimpEngine = new CSimpEngine;
return 0;
}

--
John Carson

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I connect from/to internal network by referencing it outside static nat? war_wheelan@yahoo.com Cisco 5 01-14-2006 02:14 AM
Can I connect from/to internal network by referencing it outside static nat? war_wheelan@yahoo.com Cisco 0 01-11-2006 05:48 PM
Can I connect from/to internal network by referencing it outside static nat? war_wheelan@yahoo.com Cisco 0 01-11-2006 05:48 PM
vhdl source cross-referencing tool geoffrey wall VHDL 7 07-07-2005 04:48 PM
name-based referencing of collection members? K. Shier ASP .Net 6 10-10-2003 06:09 PM



Advertisments