Click here to Skip to main content
15,906,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: EXCEL.EXE is not getting killed Pin
KTTransfer6-Dec-09 21:01
KTTransfer6-Dec-09 21:01 
QuestionDeep copy and Shallow copy w.r.t Copy Constructor and Assignment Operator Pin
hrishiS3-Dec-09 22:27
hrishiS3-Dec-09 22:27 
AnswerRe: Deep copy and Shallow copy w.r.t Copy Constructor and Assignment Operator Pin
Cedric Moonen3-Dec-09 22:55
Cedric Moonen3-Dec-09 22:55 
GeneralRe: Deep copy and Shallow copy w.r.t Copy Constructor and Assignment Operator Pin
hrishiS3-Dec-09 23:02
hrishiS3-Dec-09 23:02 
AnswerRe: Deep copy and Shallow copy w.r.t Copy Constructor and Assignment Operator Pin
Rajesh R Subramanian3-Dec-09 23:12
professionalRajesh R Subramanian3-Dec-09 23:12 
GeneralRe: Deep copy and Shallow copy w.r.t Copy Constructor and Assignment Operator Pin
Cedric Moonen3-Dec-09 23:13
Cedric Moonen3-Dec-09 23:13 
GeneralRe: Deep copy and Shallow copy w.r.t Copy Constructor and Assignment Operator Pin
hrishiS3-Dec-09 23:59
hrishiS3-Dec-09 23:59 
GeneralRe: Deep copy and Shallow copy w.r.t Copy Constructor and Assignment Operator Pin
Cedric Moonen4-Dec-09 0:12
Cedric Moonen4-Dec-09 0:12 
hrishiS wrote:
But the default constructor doesn't have any parameter with it...So in that case to which value the member variable will get initialized to?...


We are talking about the default copy constructor here. The default copy constructor receives the object from which to copy.


hrishiS wrote:
Does it meant that shallow copy is member to member copying of each member variable one by one...?
is it,...Copy Constructor is doing shallow copy?


Yes, that's what I showed you in my previous reply: a default copy constructor simply assigns all members one by one (in fact, it is using the copy constructor of each member to create them and not the assignement operator, but this is not important in the discussion here). So, in that sense a default copy constructor is doing shallow copy.


hrishiS wrote:
In that case, if we dont provide an copy constructor does the default copy constructor provides deep copy?


No, I just said the opposite: a default copy constructor does not make a deep copy. How could it do it ? You are the one how wrote the clas, so you know you have to copy some specific members (like pointers). The compiler doesn't know anything of that, he can simply assign all members from one object to the other. How can he know that for a pointer he has to allocate a new pointer and copy the content of the pointer ?

Cédric Moonen
Software developer

Charting control [v2.0]
OpenGL game tutorial in C++

QuestionHow can I close an CChildFrame within CHtmlView ? [modified] Pin
mesajflaviu3-Dec-09 22:14
mesajflaviu3-Dec-09 22:14 
Questionmulti-processes's memory sharing problem? Pin
nenfa3-Dec-09 19:45
nenfa3-Dec-09 19:45 
QuestionRe: multi-processes's memory sharing problem? Pin
norish3-Dec-09 22:12
norish3-Dec-09 22:12 
AnswerRe: multi-processes's memory sharing problem? Pin
Michael Schubert4-Dec-09 5:25
Michael Schubert4-Dec-09 5:25 
GeneralRe: multi-processes's memory sharing problem? Pin
nenfa7-Dec-09 20:08
nenfa7-Dec-09 20:08 
QuestionAccessing Dialog member Variable problem Pin
kamalilam3-Dec-09 19:30
kamalilam3-Dec-09 19:30 
AnswerRe: Accessing Dialog member Variable problem Pin
«_Superman_»3-Dec-09 19:40
professional«_Superman_»3-Dec-09 19:40 
AnswerRe: Accessing Dialog member Variable problem Pin
Madhu Nair3-Dec-09 19:44
Madhu Nair3-Dec-09 19:44 
AnswerRe: Accessing Dialog member Variable problem Pin
Cedric Moonen3-Dec-09 20:10
Cedric Moonen3-Dec-09 20:10 
AnswerRe: Accessing Dialog member Variable problem Pin
Rajesh R Subramanian3-Dec-09 21:14
professionalRajesh R Subramanian3-Dec-09 21:14 
QuestionWhich window has the focus [modified] Pin
SujayG3-Dec-09 18:17
SujayG3-Dec-09 18:17 
AnswerRe: Which window has the focus Pin
«_Superman_»3-Dec-09 18:21
professional«_Superman_»3-Dec-09 18:21 
GeneralRe: Which window has the focus Pin
SujayG3-Dec-09 18:31
SujayG3-Dec-09 18:31 
GeneralRe: Which window has the focus [modified] Pin
Madhu Nair3-Dec-09 19:28
Madhu Nair3-Dec-09 19:28 
AnswerRe: Which window has the focus Pin
vasu_sri3-Dec-09 20:18
vasu_sri3-Dec-09 20:18 
QuestionIs there a convenient way to change a System environment variable in MFC? Pin
Erik3-Dec-09 18:16
Erik3-Dec-09 18:16 
AnswerRe: Is there a convenient way to change a System environment variable in MFC? Pin
T21023-Dec-09 19:27
T21023-Dec-09 19:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.