Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS212: Object Oriented Analysis and Design Lecture 10: Copy constructor-II.

Similar presentations


Presentation on theme: "CS212: Object Oriented Analysis and Design Lecture 10: Copy constructor-II."— Presentation transcript:

1 CS212: Object Oriented Analysis and Design Lecture 10: Copy constructor-II

2 Copy copy: revisited Main Constructor Copy Constructorh f(): global functionx=h

3 What happens if we don’t use it? Compiler creates one for you in the case of simple structures The default primitive behaviour: a bit-copy. C++ compiler will still automatically create a copy-constructor if you don’t make one The process the compiler goes through to synthesize a copy- constructor is called member-wise initialization.

4 Issues with pointers 50x8975 5 A B {B=A;} Initial object Duplicate object

5 Deep vs Shallow copy Copy constructor is called only for initializations For assignment ? Operator overload ??


Download ppt "CS212: Object Oriented Analysis and Design Lecture 10: Copy constructor-II."

Similar presentations


Ads by Google