473,472 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Implementation in a *.h file

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

Sep 21 '07 #1
4 1220
Neo wrote:
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.

--
Ian Collins.
Sep 21 '07 #2
Neo
On Sep 21, 9:44 am, Ian Collins <ian-n...@hotmail.comwrote:
Neo wrote:
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.

--
Ian Collins.
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
Sep 21 '07 #3
Neo wrote:
>
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.

--
Ian Collins.
Sep 21 '07 #4
Neo
On Sep 21, 10:14 am, Ian Collins <ian-n...@hotmail.comwrote:
Neo wrote:
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.

--
Ian Collins.
Spot on!, yeah forgot that simple detail.

Thanks,
Neo

Sep 21 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
4
by: Malkocoglu | last post by:
In the good old days , i had a class that had 30 functions (let's say) There was a single include(*.H) file and i could have several implementation(*.CPP) files The reason for doing this is to...
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
4
by: Rubbrecht Philippe | last post by:
Hi there, I would like to develop an interface that when implemented in a class requires a number of shared properties or methods to be available. It seems a Shared Member can not be used as...
9
by: Christof Warlich | last post by:
Hi, consider this: template<typename Tclass X { public: void doSomething(T t); }; int main(void) { X<intx;
2
by: Bruce | last post by:
I have seen sample code that is implemented in the .h header file ("java style") and I have seen samples where the code was implemented in the ..CPP file. Which is correct? What is the best...
5
by: weidongtom | last post by:
Hi, I tried to implement the Universal Machine as described in http://www.boundvariable.org/task.shtml, and I managed to get one implemented (After looking at what other's have done.) But when I...
17
by: Jason Doucette | last post by:
I am converting a C-style unit into a C++ class. I have an implementation function that was defined in the .cpp file (so it was hidden from the interface that exists in the .h file). It uses a...
0
by: anto.anish | last post by:
Hi , Since, i did not want to write instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template...
1
by: anto.anish | last post by:
Hi , Since, i did not want to write explicit instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.