1 #include <iostream> 2 using namespace std; 3 4 class as 5 { 6 public: 7 int a; 8 const int b; 9 as():b(2) 10 { 11 a = 1; 12 } 13 ~as() 14 { 15 cout << "析构函数被调用!" << endl; 16 }; 17 18 19 private: 20 int c; 21 22 }; 23 24 int main(int argc, char *argv[]) 25 { 26 as b; 27 as c; 28 cout << b.a << endl; 29 cout << b.b << endl; 30 31 return 0; 32 }
原文:http://www.cnblogs.com/autumoonchina/p/3574361.html