#include <iostream> using namespace std; class point { public : point(int a) { x = a; cout << x << endl; } point(point & p) { x = p.x; cout << x << endl; } void addx(int a) { x += a; } private : int x; }; int main() { point p1(10), p2(p1); p2.addx(2); point p3 = p2; system("pause"); return 0; } 结果是 10 10 12 为什么不是10 10 12 12
onemoo
相关分类