undefined reference to `vtable for ...

B

bp

Hi,

Could someone to tell me what I'm doing wrong? I'm using
gcc version 3.3.4 and
ld version 2.15.90.0.3 20040415

the linker message is:

.../obj/classOpenAreaForm.o(.text+0x211): In function
`TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*)':
.../src/appforms/classOpenAreaForm.cpp:66: undefined reference to `vtable
for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x367): In function
`TOpenAreaForm::TOpenAreaForm[in-charge](TControl*)':

.../appforms/classOpenAreaForm.cpp:66: undefined reference to `vtable for
TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x4ce): In function
`TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*, int, int, int,
int, char const*)':

.../src/appforms/classOpenAreaForm.cpp:86: undefined reference to `vtable
for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x638): In function
`TOpenAreaForm::TOpenAreaForm[in-charge](TControl*, int, int, int, int,
char const*)':

.../src/appforms/classOpenAreaForm.cpp:86: undefined reference to `vtable
for TOpenAreaForm' collect2: ld returned 1 exit status

the headers of the involved classes:

TControl.h
______________
#ifndef __CONTROL_HPP_
#define __CONTROL_HPP_

class TControl
{
protected:
TControl *parent;
.....
public:
TControl(TControl *parent_);
TControl(TControl *parent_, int left_,int top_,
int width_,int height_,const char* caption_='\0');
virtual ~TControl(void);
....
};
#endif
--------------------

TForm.h
_________________
#include "classControl.hpp"

class TForm : public TControl {
protected:
virtual void Draw(void);
public:
TForm(TControl *parent_);
TForm(TControl *parent_, int left_, int top_, int width_,
int height_, const char* caption_);
.......
};
....
#endif

--------------------
TOpenAreaForm.h
_________________
#ifndef __OPENAREAFORM_HPP_
#define __OPENAREAFORM_HPP_
#include "../appgui/classForm.hpp"
// forward declaration
class TListView;

class TOpenAreaForm : public TForm {
public:
TOpenAreaForm(TControl *parent_);
TOpenAreaForm(TControl *parent_, int left_, int top_,
int width_, int height_, const char* caption_);
~TOpenAreaForm(void);
TListView* filelist;
void RefreshListItems(void);
};
....
#endif
 
X

Xenos

bp said:
Hi,

Could someone to tell me what I'm doing wrong? I'm using
gcc version 3.3.4 and
ld version 2.15.90.0.3 20040415

the linker message is:

../obj/classOpenAreaForm.o(.text+0x211): In function
`TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*)':
../src/appforms/classOpenAreaForm.cpp:66: undefined reference to `vtable
for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x367): In function
`TOpenAreaForm::TOpenAreaForm[in-charge](TControl*)':
I don't know if this will help you, but I got this one time when I declared
a virtual member but failed to define it.
 
R

Rolf Magnus

bp said:
Hi,

Could someone to tell me what I'm doing wrong? I'm using
gcc version 3.3.4 and
ld version 2.15.90.0.3 20040415

the linker message is:

../obj/classOpenAreaForm.o(.text+0x211): In function
`TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*)':
../src/appforms/classOpenAreaForm.cpp:66: undefined reference to
`vtable for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x367): In
function `TOpenAreaForm::TOpenAreaForm[in-charge](TControl*)':

../appforms/classOpenAreaForm.cpp:66: undefined reference to `vtable
for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x4ce): In
function `TOpenAreaForm::TOpenAreaForm[not-in-charge](TControl*, int,
int, int, int, char const*)':

../src/appforms/classOpenAreaForm.cpp:86: undefined reference to
`vtable for TOpenAreaForm' ../obj/classOpenAreaForm.o(.text+0x638): In
function `TOpenAreaForm::TOpenAreaForm[in-charge](TControl*, int, int,
int, int, char const*)':

../src/appforms/classOpenAreaForm.cpp:86: undefined reference to
`vtable for TOpenAreaForm' collect2: ld returned 1 exit status

the headers of the involved classes:

TControl.h
______________
#ifndef __CONTROL_HPP_
#define __CONTROL_HPP_

Identifiers containing two consecutive underscores are reserved for the
implementation (i.e. the compiler and its standard library). You are
not allowed to define any of those yourself.
class TControl
{
protected:
TControl *parent;
....
public:
TControl(TControl *parent_);
TControl(TControl *parent_, int left_,int top_,
int width_,int height_,const char* caption_='\0');

That might not do what you expect it to. '\0' is usually used as a
string termination character - a character with the value 0. But your
char* will not be assigned the address of such a 0 character. Rather it
will become a null pointer, since '\0' would just be an integer with
the value zero, which is in a pointer context interepreted a null
pointer constant, and _not_ a character constant. What you might have
wanted is:

TControl(TControl *parent_, int left_,int top_,
int width_,int height_,const char* caption_="");

virtual ~TControl(void);
....
};
#endif
--------------------

TForm.h
_________________
#include "classControl.hpp"

class TForm : public TControl {
protected:
virtual void Draw(void);

Is that Draw() member function actually defined anywhere?
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top