The code is correct..return X will make a temporary object and for that a
constructor and corresponding destructor will be called and that  object is
returned.

On Sun, Aug 21, 2011 at 12:24 PM, Puneet Chawla
<[email protected]>wrote:

> It will show error
>
> On Sun, Aug 21, 2011 at 12:21 PM, Sanjay Rajpal <[email protected]> wrote:
>
>> I think it will not be an error.
>>
>> This is because X() will create a temporary object, and when the
>> object is returned in the function calling it, then default copy
>> constructor will do bitwise copy of data members in the calling
>> function.
>>
>> Correct me if m wrong.
>>
>> On 8/20/11, sachin sabbarwal <[email protected]> wrote:
>> > class X()
>> > {
>> >
>> > X()
>> > {
>> > }
>> >
>> >
>> >
>> > X fun()
>> > {
>> > return X();      //error or what?? because constructor never returns
>> > anything so what this return statement will receive after executing x()
>> and
>> > what it will return??
>> > }
>> >
>> >
>> > };
>> >
>> > --
>> > 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.
>> >
>> >
>>
>>
>> --
>> Sanju
>> :)
>>
>> --
>> 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.
>>
>>
>
>
> --
> With regards
>   ............
> Puneet Chawla
> Computer Engineering Student
> NIT Kurukshetra
>
>  --
> 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.

Reply via email to