help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

private copy ctor with user-defined assign op


From: Bob Nelson
Subject: private copy ctor with user-defined assign op
Date: Thu, 22 Jul 2004 17:45:03 GMT
User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)

Consider this program which compiles with no errors on GNU C++ 3.3.X
and earlier. Why does GNU C++ 3.4.X require a public copy ctor in
order to compile?

---------------- [cut] --------------
class C {
private:
    C(const C &);
public:
    C(): i(0) {}
    C(int i): i(i) {}
    C &operator=(const C &rhs) {
        this->i = rhs.i;
        return *this;
    }
private:
    int i;
};

int main()
{
    C c;

    c  = C(42);
}
------------ [cut] -----------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]