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

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top