oop - C++: Copy object data in member function of base class -


suppose have 2 classes a, , b. b derived a. has no data members, b has 2 integer members.

if define method in class a, following:

void copyfrom( const a* other ) {     *this = *other; } 

and call in child class, integer data member copied?

no. known slicing problem.

this true if overload operator= in both a , b: *this = *other ever resolve a::operator=(const a&) or b::operator=(const a&) being called.


Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -