"Henrik Goldman" <he************ @mail.tele.dkwr ote in message
news:45******** *************@d read11.news.tel e.dk
Hi,
Lets say you have class A which holds all data types as private
members. Class B then inherits from A and does *only* include a set
of public functions which uses A's existing functions for
manipulation. Now A has a copy constructor and assignment operator.
What will happen if copying goes on in B? Do I need to have an
overloaded set of functions which call the same copy functions that A
has available? Or are they virtual in the sense that B's default
copying mechanisms call A's functions in the run?
Rules:
1A. The compiler-generated copy constructor of Derived automatically calls
the copy constructor of Base --- regardless of whether the Base copy
constructor is compiler- or user-defined.
1B. Any user-defined Derived copy constructor must explicitly call the Base
copy constructor if that is what is wanted: otherwise you get the Base
default (not copy) constructor. In other words, the user-defined copy
constructor of Derived functions behaves the same with respect to Base
constructors as does the user-defined (regular) constructor of Derived.
2A. The compiler generated assignment operator of Derived automatically
calls the assignment operator of Base --- regardless of whether the Base
assignment operator is compiler- or user-defined.
2B. Any user-defined Derived assignment operator does exactly what the user
defines it to do. It therefore must explicitly call the Base assignment
operator to make assignments to the Base subobject.
--
John Carson