Click here to Skip to main content
15,909,953 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: ASCII Pin
Nibu babu thomas19-May-06 0:19
Nibu babu thomas19-May-06 0:19 
GeneralRe: ASCII Pin
Maxwell Chen19-May-06 0:49
Maxwell Chen19-May-06 0:49 
AnswerRe: ASCII Pin
Hamid_RT19-May-06 1:05
Hamid_RT19-May-06 1:05 
Questionabt video buffer and stream Pin
sunita ramesh19-May-06 0:05
sunita ramesh19-May-06 0:05 
Questionwhat is deep copy and shallow copy?? Pin
voorugonda prashanth18-May-06 23:14
voorugonda prashanth18-May-06 23:14 
AnswerRe: what is deep copy and shallow copy?? Pin
Sarath C18-May-06 23:22
Sarath C18-May-06 23:22 
AnswerRe: what is deep copy and shallow copy?? Pin
Maxwell Chen18-May-06 23:23
Maxwell Chen18-May-06 23:23 
AnswerRe: what is deep copy and shallow copy?? Pin
Ganesh_T18-May-06 23:25
Ganesh_T18-May-06 23:25 
A shallow copy of an object copies all of the member field values. This works well if the fields are values, but may not be what you want for fields that point to dynamically allocated memory. The pointer will be copied. but the memory it points to will not be copied -- the field in both the original object and the copy will then point to the same dynamically allocated memory, which is not usually what you want. The default copy constructor and assignment operator make shallow copies.

A deep copy copies all fields, and makes copies of dynamically allocated memory pointed to by the fields. To make a deep copy, you must write a copy constructor and overload the assignment operator.

Deep copy needs,
If an object has pointers to dynamically allocated memory, and the dynamically allocated memory needs to be copied when the original object is copied, then a deep copy is required.

A class that requires deep copies will generally need:

i )a destructor to delete the dynamically allocated memory.

ii) a copy constructor to make a copy of the dynamically allocated memory.

iii) an overloaded assignment operator to make a copy of the dynamically allocated memory.

Cheers
"Peace of mind through Technology"
GeneralRe: what is deep copy and shallow copy?? Pin
Maxwell Chen18-May-06 23:28
Maxwell Chen18-May-06 23:28 
GeneralRe: what is deep copy and shallow copy?? Pin
Nibu babu thomas18-May-06 23:51
Nibu babu thomas18-May-06 23:51 
GeneralRe: what is deep copy and shallow copy?? Pin
Maxwell Chen18-May-06 23:54
Maxwell Chen18-May-06 23:54 
GeneralRe: what is deep copy and shallow copy?? Pin
Nibu babu thomas18-May-06 23:55
Nibu babu thomas18-May-06 23:55 
GeneralRe: what is deep copy and shallow copy?? Pin
Sebastian Schneider19-May-06 1:32
Sebastian Schneider19-May-06 1:32 
GeneralRe: what is deep copy and shallow copy?? Pin
ThatsAlok19-May-06 2:02
ThatsAlok19-May-06 2:02 
QuestionProgress Bar vc++ Pin
sudeep_br18-May-06 23:14
sudeep_br18-May-06 23:14 
AnswerRe: Progress Bar vc++ Pin
Naveen18-May-06 23:18
Naveen18-May-06 23:18 
GeneralRe: Progress Bar vc++ Pin
sudeep_br18-May-06 23:22
sudeep_br18-May-06 23:22 
GeneralRe: Progress Bar vc++ Pin
Naveen18-May-06 23:26
Naveen18-May-06 23:26 
GeneralRe: Progress Bar vc++ Pin
Cedric Moonen18-May-06 23:36
Cedric Moonen18-May-06 23:36 
GeneralRe: Progress Bar vc++ Pin
Naveen19-May-06 0:00
Naveen19-May-06 0:00 
GeneralRe: Progress Bar vc++ Pin
sudeep_br18-May-06 23:57
sudeep_br18-May-06 23:57 
GeneralRe: Progress Bar vc++ Pin
Naveen19-May-06 0:01
Naveen19-May-06 0:01 
GeneralRe: Progress Bar vc++ Pin
sudeep_br19-May-06 0:16
sudeep_br19-May-06 0:16 
GeneralRe: Progress Bar vc++ Pin
Naveen19-May-06 0:32
Naveen19-May-06 0:32 
GeneralRe: Progress Bar vc++ Pin
sudeep_br19-May-06 0:44
sudeep_br19-May-06 0:44 

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.