help me with undefined references

Discussion in 'C++' started by pavan734@gmail.com, Jun 30, 2006.

  1. Guest

    Hi,
    Iam facing problem with undefined reference linking errors.
    To explain in more detail..
    I have a class called TOP. In its constructor I have instantiated many
    other class objects using pointers.
    Iam getting errors like
    1. In function TOP::TOP(int) : undefined reference to
    CHILD1::CHILD1(int, float).
    2. In function TOP::TOP(int) : undefined reference to vtt for
    CHILD2::CHILD2(char*)
    3. In function TOP::TOP(int) : undefined reference to vtable for
    CHILD3::CHILD3( )
    4.In function TOP ::func() undefined reference to CHILD3:: func2()

    What could be possible reasons for getting such errors.
     
    , Jun 30, 2006
    #1
    1. Advertising

  2. Ian Collins Guest

    wrote:
    > Hi,
    > Iam facing problem with undefined reference linking errors.
    > To explain in more detail..
    > I have a class called TOP. In its constructor I have instantiated many
    > other class objects using pointers.
    > Iam getting errors like
    > 1. In function TOP::TOP(int) : undefined reference to
    > CHILD1::CHILD1(int, float).
    > 2. In function TOP::TOP(int) : undefined reference to vtt for
    > CHILD2::CHILD2(char*)
    > 3. In function TOP::TOP(int) : undefined reference to vtable for
    > CHILD3::CHILD3( )
    > 4.In function TOP ::func() undefined reference to CHILD3:: func2()
    >
    > What could be possible reasons for getting such errors.
    >

    You haven't linked the object files for those classes?

    Using all upper case for class names is rather an odd style.

    --
    Ian Collins.
     
    Ian Collins, Jun 30, 2006
    #2
    1. Advertising

  3. Mukian Guest

    Hi,

    I think u have to do forward declaration of classes which you created
    instances.

    Regards,
    Mukil


    wrote:
    > Hi,
    > Iam facing problem with undefined reference linking errors.
    > To explain in more detail..
    > I have a class called TOP. In its constructor I have instantiated many
    > other class objects using pointers.
    > Iam getting errors like
    > 1. In function TOP::TOP(int) : undefined reference to
    > CHILD1::CHILD1(int, float).
    > 2. In function TOP::TOP(int) : undefined reference to vtt for
    > CHILD2::CHILD2(char*)
    > 3. In function TOP::TOP(int) : undefined reference to vtable for
    > CHILD3::CHILD3( )
    > 4.In function TOP ::func() undefined reference to CHILD3:: func2()
    >
    > What could be possible reasons for getting such errors.
     
    Mukian, Jun 30, 2006
    #3
  4. Ian Collins Guest

    Mukian wrote:

    Please don't top post.
    >
    > wrote:
    >
    >>Hi,
    >> Iam facing problem with undefined reference linking errors.
    >>To explain in more detail..
    >>I have a class called TOP. In its constructor I have instantiated many
    >>other class objects using pointers.
    >>Iam getting errors like
    >>1. In function TOP::TOP(int) : undefined reference to
    >>CHILD1::CHILD1(int, float).
    >>2. In function TOP::TOP(int) : undefined reference to vtt for
    >>CHILD2::CHILD2(char*)
    >>3. In function TOP::TOP(int) : undefined reference to vtable for
    >>CHILD3::CHILD3( )
    >>4.In function TOP ::func() undefined reference to CHILD3:: func2()
    >>
    >>What could be possible reasons for getting such errors.

    >
    > Hi,
    >
    > I think u have to do forward declaration of classes which you created
    > instances.
    >

    Who's u?

    The OP is getting linker errors, not compile errors.

    --
    Ian Collins.
     
    Ian Collins, Jun 30, 2006
    #4
  5. Guest

    wrote:
    > Hi,
    > Iam facing problem with undefined reference linking errors.
    > To explain in more detail..
    >
    > What could be possible reasons for getting such errors.


    I have found out that such errors will come if a function is declared
    in a class and its definition is not provided, then also we get
    undefined reference. But Iam thinking whether there are any other
    reasons for such errors.
     
    , Jun 30, 2006
    #5
  6. Default User Guest

    wrote:

    >
    > wrote:
    > > Hi,
    > > Iam facing problem with undefined reference linking errors.
    > > To explain in more detail..
    > >
    > > What could be possible reasons for getting such errors.

    >
    > I have found out that such errors will come if a function is declared
    > in a class and its definition is not provided, then also we get
    > undefined reference. But Iam thinking whether there are any other
    > reasons for such errors.


    Maybe. How we can we possibly tell if you hid information from us? SHOW
    US THE CODE. Post a complete, minimal program the demonstrates the
    problem.

    Actually, before you do anything else, read this:

    <http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8>




    Brian
     
    Default User, Jun 30, 2006
    #6
    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. Roger Leigh
    Replies:
    8
    Views:
    446
    Karl Heinz Buchegger
    Nov 17, 2003
  2. Replies:
    3
    Views:
    458
    Victor Bazarov
    Nov 10, 2004
  3. DanielEKFA
    Replies:
    8
    Views:
    616
    DanielEKFA
    May 16, 2005
  4. Replies:
    8
    Views:
    719
    Bruno Desthuilliers
    Dec 12, 2006
  5. Replies:
    5
    Views:
    429
    Salt_Peter
    Aug 16, 2006
Loading...

Share This Page