means if i use like
main()
{
int *ptr;
abc(ptr);
}
abc(int *a)
{
}
this is shallow copy
m i ryt???
if yes thne tell xample of deep shallow..otherwise give me examples
regarding c++....cozxamples clear everythng
On Sun, Oct 2, 2011 at 11:00 AM, megha agrawal <[email protected]>wrote:
> One function passes a pointer to the value of interest to another
> function. Both functions can access the
> value of interest, but the value of interest itself is not copied. This
> communication is
> called shallow. The alternative where a complete copy is made and sent is
> known as a "deep"
> copy.
>
> On Sat, Oct 1, 2011 at 7:36 PM, rahul sharma <[email protected]>wrote:
>
>> plz give any c++ xample to xplain bit more
>>
>>
>> On Sat, Oct 1, 2011 at 6:59 PM, Bejoy kalikotay(sikkimesechora....) <
>> [email protected]> wrote:
>>
>>> 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,
>>> otherwise the copy will point to the original, with disasterous
>>> consequences.
>>>
>>> On Oct 1, 4:50 pm, rahul sharma <[email protected]> wrote:
>>> > plz xpalin waht is deep and shallow copy in c++
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.