1 / 7

Value Semantics

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

vianca
Download Presentation

Value Semantics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    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

More Related