When copy object of class type, all members shouldn't be non-public?

L

lovecreatesbeauty

--------- quotation ---------
The default method of initialization using special member functions is
to perform a bit-for-bit copy from the initializer into the object to
be initialized. This technique is applicable only to:
1. Objects of built-in types.
2. Pointers.
3. References.
4. Objects of class type, where the class has no private or protected
members, no virtual functions, and no base classes.
--------- end of quotation ---------



I saw these description when read some documents.

Does the fourth itme says that when perform initialization using copy
ctor or assignment using operator =, the all members of the class can't
be non-public. For example do this:

//Class C1;
C1 o;

C1 o2 = o;
o2 = o;


But even though deriving from a base class, there isn't such a
limitation. Why the limitation can be applied for copying object from a
same class type? Is it true in iso/iec 14882 also?
 

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,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top