Need help on this error

Discussion in 'C++' started by Neo, Jan 3, 2007.

  1. Neo

    Neo Guest

    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
     
    Neo, Jan 3, 2007
    #1
    1. Advertising

  2. 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
     
    Bjoern Doebel, Jan 3, 2007
    #2
    1. Advertising

  3. Neo

    Ondra Holub Guest

    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.
     
    Ondra Holub, Jan 3, 2007
    #3
  4. Neo

    Grizlyk Guest

    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.
     
    Grizlyk, Jan 4, 2007
    #4
  5. Neo

    Neo Guest

    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
     
    Neo, Jan 4, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ketul Patel
    Replies:
    1
    Views:
    753
    Alvin Bruney
    Nov 29, 2003
  2. TN Bella
    Replies:
    1
    Views:
    2,506
    Edward
    Jun 18, 2004
  3. Teep
    Replies:
    2
    Views:
    787
    Larry Marburger
    Jun 21, 2004
  4. =?Utf-8?B?Q2hyaXM=?=

    Help Help. I really need some help with this

    =?Utf-8?B?Q2hyaXM=?=, Jan 31, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    598
    =?Utf-8?B?SmFzb24gVmVybWlsbGlvbg==?=
    Jan 31, 2007
  5. ElementX
    Replies:
    9
    Views:
    533
    RedGrittyBrick
    Oct 1, 2008
Loading...

Share This Page