puzzlecracker wrote:
Given,
class X
{
//.....
private:
auto_ptr<Y> y;
};
In this example, if we try to
X a;
X b(a);
or
a=b;
X::(X&); constructor will be generated (assignment operator
respectively)? why? Shouldn't be X::(const X&) or suit is followed
due to auto_ptr copy constructor of that non-const form?
I thought non-const form wasn't an standard definition of automatically
generated copy constructer.
<quote>
12.8p5:
The implicitly declared copy constructor for a class X will have the
form
X::X(const X&) if
- each direct or virtual base class B of X has a copy constructor
whose first parameter is of type const B& or const volatile B&, and
- for all the nonstatic data members of X that are of a class type M
(or array thereof), each such class type has a copy constructor whose
first parameter is of type const M& or const volatile M&.107).
Otherwise, the implicitly declared copy constructor will have the form
X::X(X&)
An implicitly declared copy constructor is an inline public member of
its class.
</quote>
Hope this helps.