473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

class derived from template class

Hi All,

I've got a template class:

template < typename T >
class A: public B
{
public:
A();
virtual ~A();
virtual void PreSubclassWindow();
virtual void DefineColumns( int i ) = 0;
...
}

And I want to derive a class from 'A' called 'Derived':

class Derived: public A< DataClass >
{
Derived();
virtual ~Derived();
}

The problem is that when I link (VS.Net 2002, unmanaged), I get 'unsolved
symbols' for the constructor and all virtuals for the base class 'A', in the
derived class' object code.

e.g.
B.obj: unresolved external symbol "protected: virtual void __thiscall
A<class DataClass>::PreSubclassWindow(void)"
(?PreSubclassWindow@?$A@VDataClass@@@@MAEXXZ)

Does anyone know why this occurs? Is there something extra I have to do
syntactically to get it to work?

Thanks all!
C.
Jul 22 '05 #1
3 2459
"Corey Wirun" <co*********@nospam.ca> wrote in message
news:Y9AOc.670$T_6.418@edtnps89...
Hi All,

I've got a template class:

template < typename T >
class A: public B
{
public:
A();
virtual ~A();
virtual void PreSubclassWindow();
virtual void DefineColumns( int i ) = 0;
...
}

And I want to derive a class from 'A' called 'Derived':

class Derived: public A< DataClass >
{
Derived();
virtual ~Derived();
}

The problem is that when I link (VS.Net 2002, unmanaged), I get 'unsolved
symbols' for the constructor and all virtuals for the base class 'A', in the derived class' object code.

e.g.
B.obj: unresolved external symbol "protected: virtual void __thiscall
A<class DataClass>::PreSubclassWindow(void)"
(?PreSubclassWindow@?$A@VDataClass@@@@MAEXXZ)

Does anyone know why this occurs? Is there something extra I have to do
syntactically to get it to work?


Is all of the template code in the header? See the FAQ
(http://www.parashift.com/c++-faq-lite/) section 34 if you don't understand
why you have to do that.

--
David Hilsee
Jul 22 '05 #2
Woof! That was quick. Looks like exactly what I need. Thanks David!
"David Hilsee" <da*************@yahoo.com> wrote in message
news:s8********************@comcast.com...
"Corey Wirun" <co*********@nospam.ca> wrote in message
news:Y9AOc.670$T_6.418@edtnps89...
Hi All,

I've got a template class:

template < typename T >
class A: public B
{
public:
A();
virtual ~A();
virtual void PreSubclassWindow();
virtual void DefineColumns( int i ) = 0;
...
}

And I want to derive a class from 'A' called 'Derived':

class Derived: public A< DataClass >
{
Derived();
virtual ~Derived();
}

The problem is that when I link (VS.Net 2002, unmanaged), I get 'unsolved symbols' for the constructor and all virtuals for the base class 'A', in the
derived class' object code.

e.g.
B.obj: unresolved external symbol "protected: virtual void __thiscall
A<class DataClass>::PreSubclassWindow(void)"
(?PreSubclassWindow@?$A@VDataClass@@@@MAEXXZ)

Does anyone know why this occurs? Is there something extra I have to do
syntactically to get it to work?


Is all of the template code in the header? See the FAQ
(http://www.parashift.com/c++-faq-lite/) section 34 if you don't

understand why you have to do that.

--
David Hilsee

Jul 22 '05 #3
"Corey Wirun" <co*********@nospam.ca> wrote in
news:Y9AOc.670$T_6.418@edtnps89:
Hi All,

I've got a template class:

template < typename T >
class A: public B
{
public:
A();
virtual ~A();
virtual void PreSubclassWindow();
virtual void DefineColumns( int i ) = 0;
...
}

And I want to derive a class from 'A' called 'Derived':

class Derived: public A< DataClass >
{
Derived();
virtual ~Derived();
}

The problem is that when I link (VS.Net 2002, unmanaged), I get
'unsolved symbols' for the constructor and all virtuals for the base
class 'A', in the derived class' object code.

e.g.
B.obj: unresolved external symbol "protected: virtual void __thiscall
A<class DataClass>::PreSubclassWindow(void)"
(?PreSubclassWindow@?$A@VDataClass@@@@MAEXXZ)

Does anyone know why this occurs? Is there something extra I have to
do syntactically to get it to work?


Where's the body of PreSubclassWindow? It's a virtual, not a pure
virtual.... so it must have a body....
Jul 22 '05 #4

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

Similar topics

12
by: Tim Clacy | last post by:
Your expertise will be appreciated... Here's a general templatised class; all specialisations of this class should have a pointer to a specialisation of the same, templatised type: ...
4
by: uvts_cvs | last post by:
template <class T> class foo { public: template <class Tin> T bar (Tin) {return T();} }; class derived : public foo<derived> {
9
by: Daniel Kay | last post by:
Hello! I have written two template classes which implement the observerpattern in C++. I hope I manage to desribe the problem I have. template<class T> class Observer { /* ... */ }; ...
3
by: Chris | last post by:
I am having a very strange problem involving virtual functions in template classes. First of all, here is an extremely simplified structure of the two classes I am having problems with. ...
4
by: Jeff | last post by:
The derived class below passes a reference to an object in its own class to its base calss constructor. The code compiles and will run successfully as long as the base class constructor does not...
4
by: michael.alexeev | last post by:
Hi all. Consider the following code fragment: #include <string> struct Base{ virtual ~Base() {} }; template <typename T> struct Derived : public Base {}; Base* Create (int param) { switch...
2
by: RitualDave | last post by:
I get a C2811 error when I compile the following (with the /clr switch): template <class T> ref class Base {}; template <template <class> class TBase> ref class Derived : TBase<int> {};
9
by: Mirko Puhic | last post by:
Is there a way to properly do this? struct Derived; struct Base{ Derived der; };
17
by: Jef Driesen | last post by:
Suppose I have a datastructure (actually it's a graph) with one template parameter (the property P for each edge and vertex): struct graph<P>; struct vertex<P>; struct edge<P>; I also have...
15
by: Juha Nieminen | last post by:
I'm sure this is not a new idea, but I have never heard about it before. I'm wondering if this could work: Assume that you have a common base class and a bunch of classes derived from it, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
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...

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.