Implementation in a *.h file

N

Neo

Hi,
I have a single a.h file which also contains the class implementation
because it is small and I have included this in another file which
needs this class definitions. It compiles fine but I get a linker
error saying "undefined symbol **classx" which is the class defined in
a.h file. Is there something I am missing?


Thanks,
Neo
 
I

Ian Collins

Neo said:
Hi,
I have a single a.h file which also contains the class implementation
because it is small and I have included this in another file which
needs this class definitions. It compiles fine but I get a linker
error saying "undefined symbol **classx" which is the class defined in
a.h file. Is there something I am missing?
Post an example.
 
N

Neo

Post an example.

ok, here it is-
//a.h
class D: public B {
.....
.....
D(){}
~D(){}
.....
.....
};
//end a.h

//test.h
#include a.h
class C {
D *Dptr;
....
....
C() {
Dptr = new D;
....
}

};
// end test.h

I just deciphered the undefined symbol and it happens to the vtable of
class D. I have made the destructor of B to be virtual.

Thanks,
Neo
 
I

Ian Collins

Neo said:
I just deciphered the undefined symbol and it happens to the vtable of
class D. I have made the destructor of B to be virtual.
Sounds like you are missing the definition of a virtual method.
 

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

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,649
Latest member
MargaretCo

Latest Threads

Top