Mooophy / Cpp-Primer

C++ Primer 5 answers
Creative Commons Zero v1.0 Universal
8.06k stars 3k forks source link

fix: fix 13.16 #833

Open Crazyokd opened 1 year ago

Crazyokd commented 1 year ago

you can verify it by execute code below:

#include <iostream>

using namespace std;

class X {
        public:
                int mysn = 0;
                X() {}
                X(const X&orig): mysn(orig.mysn + 1) {
                        cout << "copy constructor " << (orig.mysn + 1) << endl;
                }
};

void f (const X &x) {
        cout << x.mysn << endl;
}

int main() {
        X a, b = a, c = b;
        f(a);
        f(b);
        f(c);
        return 0;
}