asdf said:
How to understand the last paragraph? Who'd like to give me an
example?
There is a third possibility: The element type might be of a class
type that does not define any constructors. In this case, the library
still creates a value-initialized object. It does so by
value-initializing each member of that object.
Is this the paragraph you want to understand?
'Element', eh? Probably talking about arrays. Class that does not
define "any" constructors means that it has an implicitly-declared
and implicitly-defined (hopefully) default constructor (c-tor that
doesn't take any arguments). If it's defined (IOW, if all members
to be initialised *can* be initialised using default-initialisation),
then initialisation of an array [of objects] of such class will make
all elements of the array default-initialised.
class A { int a; public: A() : a() {} };
class B { A a; };
int main() {
B *pb = new B[10](); // ten elements, all value-initialised
}
In the example above, each 'a' of each 'B' will have it's 'a' set
to 0 (value-initialisation).
If this is not what the book is talking about, then you have to
explain what you're asking about, by quoting a bit more of the book.
I don't have a copy.
V