Hi Jim!

On Mon, Nov 18, 2013 at 1:33 AM, Jim Michaels <j...@boohoo.com> wrote:
> Hi.
> I noticed that c++ templates define types using the keyword class,

However (as of a while ago), you can also use the keyword "typename"
for this purpose, i.e. "template<typename T> void template_function ...",
and the like.

> and then
> you use them you plug in the data type, like double.

Yes ...

> is double actually a class?

No, double (and int, etc.) is "naive" or "built-in" type, or whatever
they call it.
It is not a class.

> does it have data members I can look at? because
> if it does,

It doesn't (not a class).

> ...
> I have not seen this discussed because I was told it's an integral data
> type. but this doesn't explain why it can be used with class... I was taught
> only classes could be used with class, (but then we just kinda did templates
> and didn't discuss).

I think that the use of the keyword "class" in "template <class T> void func"
came about because the keyword class was available, and not ambiguous
in this context, and at the time there was not the desire to introduce a new
keyword.  But it really means "type" or "typename" or whatever, and applies
equally well to built-in types as to classes.  So it's a somewhat inaccurate
use of the word "class".

Then the keyword "typename" was introduced (maybe in c++03?), and one
of its uses was as a synonym for "class" in "template <class T>".  I prefer
using the newer version, "template <typename T>", basically for the reason
you give:  "class" is a little bit inaccurate and confusing, while "typename"
more accurate reflects what "template <typename T>" means.

But this is all just a very minor, superficial detail, and, in
practice, you should
get used to seeing both "template <class T>" and template <typename T>"
in real (and high-quality) code.

> any help appreciated.
>
> maybe I need to take this up on a c++ newsgroup?

Yes, one of the c++ newsgroups might be a little better fit, as this is a
pure c++ question, and not specific to mingw-w64.

> but I had hopes someone
> from the compiler set would know an answer to this. I don't have
> stroutsrup's book available to me.
>
> -------------
> Jim Michaels
> ...


Happy Generic Hacking!


K. Frank

------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to