Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 21st, 2008, 09:55 AM
kvnil
Guest
 
Posts: n/a
Default default template

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=4096struct A { enum {size = S}; };

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

Thanks, Kev



  #2  
Old March 21st, 2008, 10:25 AM
White Wolf
Guest
 
Posts: n/a
Default Re: default template

"kvnil" <kvnil@mail.ruwrote:
Quote:
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=4096struct 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


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles