Re: Function Returning a local object???

From: John Harrison (john_andronicus_at_hotmail.com)
Date: 09/07/04


Date: Tue, 7 Sep 2004 14:11:21 +0100


>
> Yes if you do not define the operator= the compiler will provide one
> for you. What is does is byte copying. The compiler will also create
> the constructor, destructor and copy constructor if you don't defined
> them.
>

Not true, it does member copying.

class X
{
    std::string y;
    int z;
};

X::operator= will copy the member y using std::string::operator= (this is
not a byte copy), and will also copy the member z (this is a byte copy).

Same principle for copy constructor.

john



Relevant Pages