VC 2005 - templates - partial specialization

V

VB

Hi,
I was attempting to implement partial specialization using VC 2005.
However i cannot get my code to compile :( .. Can you please help me?


template <typename TYPE1>
class myClass<TYPE1, int>
//C2143: syntax error : missing ';' before '<'
//C2059: syntax error : '<'
{//C2143: syntax error : missing ';' before '{'
//error C2447: '{' : missing function header (old-style formal list?)
private:
TYPE1 xUnspecifiedParameter;
int xSpecifiedParameter;
public:
myClass(TYPE1 xUnspecifiedParameter, int xSpecifiedParameter):
xUnspecifiedParameter(xType1),
xSpecifiedParameter(xInt)
{}

};

if i remove <TYPE1, int> from class myClass<TYPE1, int> the compiler
errors go away but instantiating myclass causes errors ...
myClass<int,int> myInstance(2,3);
the compiler complains
error C2977: 'myClass' : too many template arguments
error C2514: 'myClass' : class has no constructors
 
N

Noah Roberts

VB said:
Hi,
I was attempting to implement partial specialization using VC 2005.
However i cannot get my code to compile :( .. Can you please help me?

Where is the definition of myClass? We need that part to be able to
help you.
template <typename TYPE1>
class myClass<TYPE1, int>

This is partial specialization of some previously defined and currently
unknown type.
 
V

VB

Noah Roberts wrote:

I read about partial specializations again. Now i understand them
better. I had misinterpreted their usage.

thanks.
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top