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

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -