Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Need help on this error

Reply
Thread Tools

Need help on this error

 
 
Neo
Guest
Posts: n/a
 
      01-03-2007
I have the following code structure-
class A {
public:
virtual void foo_a()=0;
};

class B {
public:
virtual void foo_b()=0;
};

class AB: public A, public B {
public:
void foo_a(){...}
void foo_b(){...}
AB(){...}
};

And further I have pointers to objects of class AB in my other modules.
Now I am getting multiples of this error: "Undefined reference to VTT
for AB". I have taken care not to leave any functions undefined which
are declared in abstract classes A and B. I need help badly in
resolving this as I am new to c++.

thanks,
Neo

 
Reply With Quote
 
 
 
 
Bjoern Doebel
Guest
Posts: n/a
 
      01-03-2007
Neo wrote:
> I have the following code structure-
> class A {
> public:
> virtual void foo_a()=0;
> };
>
> class B {
> public:
> virtual void foo_b()=0;
> };
>
> class AB: public A, public B {
> public:
> void foo_a(){...}
> void foo_b(){...}
> AB(){...}
> };
>
> And further I have pointers to objects of class AB in my other modules.
> Now I am getting multiples of this error: "Undefined reference to VTT
> for AB". I have taken care not to leave any functions undefined which
> are declared in abstract classes A and B. I need help badly in
> resolving this as I am new to c++.


Compiles for me with g++-3.4 and g++-4.1.2 - perhaps it is a compiler
issue. If I run g++ with -Wall, then I'm told that virtual destructors are
missing:

> bla.cc:19: warning: ‘class A’ has virtual functions but non-virtual destructor
> bla.cc:24: warning: ‘class B’ has virtual functions but non-virtual destructor
> bla.cc:29: warning: ‘class AB’ has virtual functions but non-virtual destructor


Bjoern
 
Reply With Quote
 
 
 
 
Ondra Holub
Guest
Posts: n/a
 
      01-03-2007

Neo napsal:
> I have the following code structure-
> class A {
> public:
> virtual void foo_a()=0;
> };
>
> class B {
> public:
> virtual void foo_b()=0;
> };
>
> class AB: public A, public B {
> public:
> void foo_a(){...}
> void foo_b(){...}
> AB(){...}
> };
>
> And further I have pointers to objects of class AB in my other modules.
> Now I am getting multiples of this error: "Undefined reference to VTT
> for AB". I have taken care not to leave any functions undefined which
> are declared in abstract classes A and B. I need help badly in
> resolving this as I am new to c++.
>
> thanks,
> Neo


You should post minimalized, but complete code, which does not compile.
You should define virtual destructor for A and B, but I do not think it
is problem here.

 
Reply With Quote
 
Grizlyk
Guest
Posts: n/a
 
      01-04-2007

Neo wrote:

> Now I am getting multiples of this error: "Undefined reference to VTT
> for AB". I have taken care not to leave any functions undefined which
> are declared in abstract classes A and B. I need help badly in
> resolving this as I am new to c++.


It is maybe link time error. Maybe you do not include no one object
file with compiled class declaration. For example (if I do not do
mistake) the error can occure due to improper use of #pragma
interface/#pragma implementation for gxx compiler.

 
Reply With Quote
 
Neo
Guest
Posts: n/a
 
      01-04-2007

Ondra Holub wrote:
> Neo napsal:
> > I have the following code structure-
> > class A {
> > public:
> > virtual void foo_a()=0;
> > };
> >
> > class B {
> > public:
> > virtual void foo_b()=0;
> > };
> >
> > class AB: public A, public B {
> > public:
> > void foo_a(){...}
> > void foo_b(){...}
> > AB(){...}
> > };
> >
> > And further I have pointers to objects of class AB in my other modules.
> > Now I am getting multiples of this error: "Undefined reference to VTT
> > for AB". I have taken care not to leave any functions undefined which
> > are declared in abstract classes A and B. I need help badly in
> > resolving this as I am new to c++.
> >
> > thanks,
> > Neo

>
> You should post minimalized, but complete code, which does not compile.
> You should define virtual destructor for A and B, but I do not think it
> is problem here.


I am sorry I dont really know what the hell is happening. I also cant
post the complete code as it requires other libraries which are
numerous. But If it will help I noticed that only when I instatiate
objects of class AB in the upper module does this error come up else it
goes fine. I am using gcc 3.4.4 compiler. Or if I can get the
exhaustive list of conditions for which I get such an error I could
check for each of them in turn.

thanks,
neo

 
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
Help Help, I am intermediate in Java...need help in follow case ElementX Java 9 10-01-2008 08:02 PM
Help Help. I really need some help with this =?Utf-8?B?Q2hyaXM=?= ASP .Net 3 01-31-2007 09:33 PM
re_---need help Network Adapters!!!! NEED HELP!!!! hedayatniac@gmail.com Computer Support 4 08-13-2006 01:03 AM
Please help!!! Need datagrid selection to fill textboxes...Need quick!! TN Bella ASP .Net 1 06-18-2004 01:31 AM
Need help to understand this code error 'server error in /online application' Ketul Patel ASP .Net 1 11-29-2003 04:10 PM



Advertisments