default template

K

kvnil

Let's say I have a template

template<int S = 4096>
struct A {
....
}

why can't be used as just A? For example, see the following program (which
doesn't compile because "A" is used instead, of A<10>, for instance):

template <int S=4096> struct A { enum {size = S}; };

int main(int argc, char* argv[]) {
printf("%d\n",A::size);
}

Thanks, Kev
 
W

White Wolf

kvnil said:
Let's say I have a template

template<int S = 4096>
struct A {
...
}

why can't be used as just A? For example, see the following program (which
doesn't compile because "A" is used instead, of A<10>, for instance):

template <int S=4096> struct A { enum {size = S}; };

int main(int argc, char* argv[]) {
printf("%d\n",A::size);
}

A template instance's name always have to have those angle brackets. I may
write now something completely stupid (I have never needed a template with
all params defaulted), but I think that the instance of that template should
be called: A<>, so your expression is A<>::size...

Attila
 

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,777
Messages
2,569,604
Members
45,235
Latest member
Top Crypto Podcasts_

Latest Threads

Top