Template Problem

Started by
5 comments, last by MadKeithV 18 years, 7 months ago
I'm trying to compile this peice of code and get an error message about template explicit specification before definition under Visual C++ 6. template<class T> union myunion { ....... }; template<class T> class myclass { .......... union myunion<T> *p; }; What's the problem here? I'm passing the same type to be used for the union in the class. Thanks.
Advertisement
Are these in the same file or different files?
--random_thinkerAs Albert Einstein said: 'Imagination is more important than knowledge'. Of course, he also said: 'If I had only known, I would have been a locksmith'.
Yes. they are in the same file.
What error number is this? Often, searching Google for that number'll give you everything you need to know.

Also, consider that VC6 has legendary template support. Or lack thereof.

CM
If I wanted to search it on google I would not post it here.
Quote:Original post by quaker
If I wanted to search it on google I would not post it here.

Well then why not provide a better description of your problem? Post actual code that breaks, not an approximation of what you think might be causing the problem -- and then give us the exact error you are getting rather than "an error message about template explicit specification" which doesn't even make sense. Did you mean explicit template specialization possibly? It is not our responsibility to try to figure out what you mean. Take the little time that it takes to form a better description of the situation.
Quote:Original post by quaker
If I wanted to search it on google I would not post it here.


If you actually want an answer here you shouldn't have posted this reply either.
There's a certain etiquette to asking questions on a forum. I'll post the link again: Asking Questions the Smart Way .

Anyway - try removing the "union" tag before the union member declaration. That strikes me as a C-ism - though I don't have a VC6.0 to test if that is the problem.

I.e.
// instead of// union myunion<T> *pmyunion<T> *p;
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.

This topic is closed to new replies.

Advertisement