need help with undefined reference errors

Discussion in 'C++' started by boyphp, May 2, 2007.

  1. boyphp

    boyphp Guest

    I'm getting the following undefined reference errors:

    foo_test.o(.gnu.linkonce.t._ZN7CFooD1Ev+0x18): In function
    `CFoo::~CFoo()':
    : undefined reference to `vtable for CFoo'
    foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x19): In function
    `CFoo::CFoo()':
    : undefined reference to `CFoo::rmap'
    foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x30): In function
    `CFoo::CFoo()':
    : undefined reference to `vtable for CFoo'

    The implementation of the concerned functions is given below. I'm
    pretty sure it is reading the file. What exactly could be going wrong?
    ------------------------------------------------------------------------------------------------------------------
    class CFoo : public CIFoo
    {
    public:
    CFoo() : CIFoo( PID_FOO, rmap) {};

    CFoo( const CFoo& c ) : CIFoo( PID_Foo, rmap )
    {
    }

    ~CFoo()
    {
    }
    private:
    char* rmap;
    };
    boyphp, May 2, 2007
    #1
    1. Advertising

  2. boyphp

    Guest

    Without the full source code, I am guessing the base class `CIFoo' has
    no virtual destructor.
    , May 2, 2007
    #2
    1. Advertising

  3. boyphp wrote:
    > I'm getting the following undefined reference errors:
    >
    > foo_test.o(.gnu.linkonce.t._ZN7CFooD1Ev+0x18): In function
    > `CFoo::~CFoo()':
    >> undefined reference to `vtable for CFoo'

    > foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x19): In function
    > `CFoo::CFoo()':
    >> undefined reference to `CFoo::rmap'

    > foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x30): In function
    > `CFoo::CFoo()':
    >> undefined reference to `vtable for CFoo'

    >
    > The implementation of the concerned functions is given below. I'm
    > pretty sure it is reading the file. What exactly could be going wrong?

    [..]

    Quoting the Standard:
    "A virtual member function shall be declared pure _or_ defined
    _or_ both."

    That means you cannot declare a virtual function but not define it.
    Also, it's possible that the base class of CFoo has pure d-tor...
    The cod you posted does not have enough information in it.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, May 2, 2007
    #3
    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. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    937
    Mark Goldin
    Jan 17, 2004
  2. Mantorok Redgormor
    Replies:
    70
    Views:
    1,748
    Dan Pop
    Feb 17, 2004
  3. Shuaib
    Replies:
    1
    Views:
    1,010
    Shuaib
    Aug 19, 2006
  4. Replies:
    1
    Views:
    341
  5. Replies:
    9
    Views:
    2,862
Loading...

Share This Page