奇怪的类复制

///程序填空,使其输出9 22 5 #include using namespace std; class Sample { public: int v; Sample() { v=0; } Sample(int i) { v=i; } Sample(Sample const &a) { v=a.v+2; }}; void PrintAndDouble(Sample o) { cout << o.v; cout << endl; } int main() { Sample a(5); Sample b = a; PrintAndDouble(b); Sample c = 20; PrintAndDouble(c); Sample d; d = a; cout << d.v; return 0; }

    推荐阅读