help me with undefined references

P

pavan734

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.
 
I

Ian Collins

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.
 
M

Mukian

Hi,

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

Regards,
Mukil
 
I

Ian Collins

Mukian wrote:

Please don't top post.
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.
 
P

pavan734

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.
 
D

Default User

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
 

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,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top