Are Built-in Data Types also Classes

  • Thread starter lovecreatesbeauty
  • Start date
L

lovecreatesbeauty

Prof. Bjarne Stroustrup said "built-in data types have default
constructor" at §10.4.2 in `TC++PL, special ed.'.

He also said that "built-in data types are not classes" at §11.4 in
`TC++PL, special ed.'.

(Sorry, I'm reading a Chinese edition of the book, and can't get a
English edition handy currently. Perhaps these words are not same as
his book, but I think the meaning is the same.)

Can I take Built-in Data Types as Compiler Defined Types. Then it's the
same as class (UDT) at this point.
 
V

Victor Bazarov

lovecreatesbeauty said:
Prof. Bjarne Stroustrup said "built-in data types have default
constructor" at §10.4.2 in `TC++PL, special ed.'.

Yes, _syntactically_ and _semantically_, not *literally*.
He also said that "built-in data types are not classes" at §11.4 in
`TC++PL, special ed.'.
Yes.

(Sorry, I'm reading a Chinese edition of the book, and can't get a
English edition handy currently. Perhaps these words are not same as
his book, but I think the meaning is the same.)

Pretty much. I don't have my copy of the SE handy either, but I am
certain that you quote it correctly.
Can I take Built-in Data Types as Compiler Defined Types. Then it's
the same as class (UDT) at this point.

What do you mean by "can I take"? The important difference is that
the built-in types (a) have some conversions defined that are implicit
and (b) have predefined operators that cannot be redefined and (c)
have no member functions. The similarity is only in two areas: the
built-in types can be "constructed" using syntax "type()", and there
is a "pseudo-destrutor call" defined for them, like "~int()". Those
things were added to them so that they can be used with templates,
IIUIC.

V
 
R

Ron Natalie

lovecreatesbeauty said:
Prof. Bjarne Stroustrup said "built-in data types have default
constructor" at §10.4.2 in `TC++PL, special ed.'.

Doesn't say that in the English version. However the English text
is pretty much WRONG and always has been wrong for C++. Not even
all class types work the way he describes due to the woefully
stupid decision of forgetting to default initialize pod types.
He also said that "built-in data types are not classes" at §11.4 in
`TC++PL, special ed.'.

Correct, they are not.
Can I take Built-in Data Types as Compiler Defined Types. Then it's the
same as class (UDT) at this point.
No, on a number of points.
 
M

Mike Wahler

Ron Natalie said:
Doesn't say that in the English version. However the English text
is pretty much WRONG and always has been wrong for C++. Not even
all class types work the way he describes due to the woefully
stupid decision of forgetting to default initialize pod types.

Someone *decided* to *forget*? Hmmm. :)

-Mike
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top