析构函数:与构造函数相反的,C++中~符号,撤销被占用的内存前进行一些处理
C++共享数据进行保护 const 关键字,既能在一定范围内共用,不能不被其他数据修改类似于Java中final
复制构造函数:类对象中内部结构较为复杂,还有各种成员变量
1 /*对拷贝构造函数理解*/ 2 #include<iostream> 3 class Example{ 4 private : 5 int a; 6 7 public : 8 Example (int b) 9 { 10 a=b; 11 } 12 /*拷贝构造函数*/ 13 Example(const Example& c) 14 { 15 a=c.a; 16 17 } 18 19 void show() 20 { 21 std::cout<<a<<std::endl; 22 23 24 } 25 }; 26 27 int main() 28 { 29 Example A(100); 30 Example B=A; 31 B.show(); 32 return 0; 33 }
原文:http://www.cnblogs.com/woainifanfan/p/6480917.html