Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Modern CPP Design related

Reply
Thread Tools

Modern CPP Design related

 
 
LRS Kumar
Guest
Posts: n/a
 
      06-25-2004
In Section 1.4 of Alexandrescu's Modern C++ Design, he states the
following:

<quote>
1. You cannot specialize structure. Using templates alone you cannot
specialize the structure of a class (its data members). You can only
specialize only functions.
</quote>

What does the author mean by that? Wouldn't the following constitute
"specializing structure"?

template<typename T>
class A {
T t;
};

template<>
class A<int> {
float t;
std::string s;
};


Thanks in advance for your time.

Terribly confused,
LRS
 
Reply With Quote
 
 
 
 
Wolfgang Meyer
Guest
Posts: n/a
 
      06-26-2004
LRS Kumar wrote:

> In Section 1.4 of Alexandrescu's Modern C++ Design, he states the
> following:
>
> <quote>
> 1. You cannot specialize structure. Using templates alone you cannot
> specialize the structure of a class (its data members). You can only
> specialize only functions.
> </quote>
>
> What does the author mean by that? Wouldn't the following constitute
> "specializing structure"?
> [...]


Yes, it does. But the point is that you have to repeat the whole class
definition while for member _functions_ you can specialize just one
function.
See:
http://groups.google.com/groups?hl=e....de%26rnum%3D5

Here Alexandrescu answers exactly this questions.

Wolfgang

 
Reply With Quote
 
 
 
 
LRS Kumar
Guest
Posts: n/a
 
      06-26-2004
Wolfgang Meyer <> wrote in message news:<40dca689$0$12451$>.. .
>
> Yes, it does. But the point is that you have to repeat the whole class
> definition while for member _functions_ you can specialize just one
> function.
> See:
> http://groups.google.com/groups?hl=e....de%26rnum%3D5
>
> Here Alexandrescu answers exactly this questions.
>
> Wolfgang


Thanks a lot. That link helped.

LRS
 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CPP Output Question - related to copy-constructor and return by value sanjay C++ 1 10-09-2008 01:16 PM
Free online test in C, CPP / Placement papers / CPP,C Interview Questions www.hitechskill.com C++ 0 04-09-2006 10:53 AM
when i compile the cpp file(cmdargs.cpp) int main(int argc, wchar_t* argv[]) Vinu C++ 9 05-05-2005 04:11 AM
Method inlined in source1.cpp and called in source2.cpp Alex Vinokur C++ 7 11-15-2004 09:14 PM
What is better /standard for creating files. a cpp file with header or cpp and seperate file for header DrUg13 C++ 1 02-10-2004 09:20 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57