By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

VC 2005 - templates - partial specialization

P: n/a
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

Jun 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

VB wrote:
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.
//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


Jun 26 '06 #2

P: n/a
VB
Noah Roberts wrote:

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

thanks.

Jun 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.