referencing

M

Michael Sgier

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
 
J

John Carson

Michael Sgier said:
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.
 
J

John Harrison

Michael said:
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
 
M

Michael Sgier

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
 
M

Michael Sgier

Maybe like this it's clearer. My simpengine.h:

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

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

John Carson

Michael Sgier said:
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;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top