template default parameters?

G

Gernot Frisch

Hmm...

template <class flt=double> MyVector
{
};

MyVector v;

gives error C2955: template argument list required

But... I said it should be "double" by default, didn't I?
 
T

TonyO

Gernot said:
template <class flt=double> MyVector
{
};

MyVector v;

MyVector said:
gives error C2955: template argument list required

But... I said it should be "double" by default, didn't I?

You must always supply the angle-bracket pair when instantiating a
class template, even if you don't need to supply any actual arguments
between them (as in your example).

Tony.
 
B

ben

You must always supply the angle-bracket pair when instantiating a
class template, even if you don't need to supply any actual arguments
between them (as in your example).

Tony.

Alternatively, you can typedef a unbracketed name and just use it, just as
std::string is a typedef of std::basic_string<char, ...>

ben
 

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

No members online now.

Forum statistics

Threads
474,297
Messages
2,571,536
Members
48,282
Latest member
Xyprime

Latest Threads

Top