70 likes | 191 Views
Value Semantics. determine how the value(s) of one object are copied to another objectin C the value semantics consist of the assignment operator and the copy constructorthese allow assignment of one object to another and the creation of one object from another. for simple/static objects. the de
E N D
1. Value Semantics CS-240 & CS-341
Dick Steflik
2. Value Semantics determine how the value(s) of one object are copied to another object
in C++ the value semantics consist of the assignment operator and the copy constructor
these allow assignment of one object to another and the creation of one object from another
3. for simple/static objects the default assignment operator and copy constructor will do what is needed; i.e. a member by member copy of the elements making up the object.
4. for dynamic objects where the private data includes dynamically allocated data (ex. dynamic array) we must overload both the default copy constructor and the default assignment operator.
5. implementation
6. copy constructor
7. overload assignment operator