By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

help me with undefined references

P: n/a
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 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
pa******@gmail.com 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.
Jun 30 '06 #2

P: n/a
Hi,

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

Regards,
Mukil
pa******@gmail.com 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.


Jun 30 '06 #3

P: n/a
Mukian wrote:

Please don't top post.

pa******@gmail.com 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.
Jun 30 '06 #4

P: n/a

pa******@gmail.com 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 '06 #5

P: n/a
pa******@gmail.com wrote:

pa******@gmail.com 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
Jun 30 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.