linking problem with nested class in template class

D

Dominik Fritz

Hi,

I have a template class which contains a nested class. The .cpp file is
included at the end of the header file. If I write the implementation of
a member function of my nested class in this .cpp file (i.e. not inside
the declaration of the class) the linker complains about a missing
symbol. If I write the implementation inside the declaration everything
is fine.
Any Ideas why this happens (I use VC++6)?


// myclass.h


template <typename T>
class myclass
{
class mynestedclass
{
void memberfunction () ;
}

}

#include myclass.cpp


//myclass.cpp

template <typename T>
void myclass<T>::mynestedclass::memberfunction ()
{
// some code
}
 
V

Victor Bazarov

Dominik said:
I have a template class which contains a nested class. The .cpp file is
included at the end of the header file. If I write the implementation of
a member function of my nested class in this .cpp file (i.e. not inside
the declaration of the class) the linker complains about a missing
symbol. If I write the implementation inside the declaration everything
is fine.
Any Ideas why this happens (I use VC++6)?

Because VC++ v6 is really bad with templates. Put the definition inside
the class. Upgrade your compiler ASAP.
 
D

Dominik Fritz

Hi Victor,

Victor said:
Dominik Fritz wrote:
[...]

Because VC++ v6 is really bad with templates. Put the definition inside
the class. Upgrade your compiler ASAP.

thanks for your fast reply. Unfortunately there are other constraints
why I have to use VC++ 6 :(

Dominik
 

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
473,777
Messages
2,569,604
Members
45,230
Latest member
LifeBoostCBD

Latest Threads

Top