标签:
代码示例
1 #include <iostream> 2 using namespace std; 3 class A 4 { 5 public: 6 A(int x){ i = x; cout << "构造函数执行!" << i << endl; } 7 ~A(){ cout << "析构函数执行!" << i << endl; } 8 void get(){ cout << i << endl; } 9 private: 10 int i; 11 }; 12 int main() 13 { 14 A a(99); 15 a.get(); 16 a = 1000; 17 a.get(); 18 a = A(2); 19 a.get(); 20 A b(35); 21 return 0; 22 }
输出结果
标签:
原文地址:http://www.cnblogs.com/table/p/4705334.html