拷贝构造函数
摘要:
什么是拷贝构造函数拷贝构造函数是一种特殊的构造函数,它的形式如下。struct Test{ Test() { } Test(const Test& other) // 拷贝构造函数 { cout << "Copy constructor" << endl ; }};什么情况下调用拷贝构造函数以下几种情况会调用拷贝构造函数。以一个对象初始化另一个对象函数以某个对象为参数函数返回某个对象初始化序列式容器的元素struct Test{ Test() { } Test(const Test& other) { ... 阅读全文
posted @ 2010-07-05 21:40 翰墨小生 阅读(1246) 评论(0) 推荐(1) 编辑