class nested in template class: Dev-C works while VC6 not

L

LiDongning

Hi,
I am trying to create a class nested in a template. Following piece of
codes works in Dev-C but can not be complied in VC6 with following
error message.

error LNK2001: unresolved external symbol "public: __thiscall
Ta<double>::Tb::Tb(double)" (??0Tb@?$Ta@N@@QAE@N@Z)

Could somebody give a helpful hand? Thanks much.

-------------------------------------------------------------------


template <class T>
class Ta
{
public:
class Tb
{
public:
T x;
Tb(T=T(0));
};
Tb u;
};

template <class T>
Ta<T>::Tb::Tb(T inx):x(inx)
{
}

int main(int argc, char *argv[])
{

Ta<double> xta;
Ta<double>::Tb xtab;

system("PAUSE");
return EXIT_SUCCESS;
}
 
L

LiDongning

Thanks much Sam.


You will will have a better chance of finding a helpful hand in an
appropriate microsoft.* newsgroup, where you'll find many more people who
are familiar with Microsoft's compilers.

From purely a language viewpoint, I see nothing wrong with the sample
code that you posted. gcc compiles and links the sample code without any
issues. This is either a bug in VC6, or you perhaps are using a
configuration setting or a compiler option with VC6 that enables some
nondefault processing related to instantiation of template code. Most
compiler have optional switches that enable alternate logic for how template
instantiation gets implemented, which may result in non-standard behavior,
but some more optimal implementation in some fashion that requires specific
code configuration.

This is something that you should be able to clarify in the appropriate
microsoft.* newsgroup.

 application_pgp-signature_part
< 1KViewDownload
 
R

red floyd

Hi,
I am trying to create a class nested in a template. Following piece of
codes works in Dev-C but can not be complied in VC6 with following
error message.

Stop right there. VC6 is ancient, pre-standard, and is known to have
borked
template support.

Use a modern compiler.
 

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,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top