您的位置:首页 > 数据库

感悟:与数据库一起飘泊的日子(转)

2010-06-03 17:40 246 查看
There is a lot of syntax inconsistencies in C++, which makes C++ harder for

people to understand. For example, = sometimes denotes copy assignment. 

Sometimes it denotes copy construction.

#include <iostream>
using namespace std;

class Thing {
public:
Thing() {
cout << "Thing constructor\n";
}
Thing(const Thing& other) {
cout << "Thing copy constructor\n";
}
Thing& operator = (const Thing& other) {
cout << "Thing copy assignment\n";
}
};

int main(int argc, const char *argv[]) {
Thing t1; // constructor
Thing t2 = t1; // copy constructor (initialization by copy)
Thing t3(t1); // copy constructor
t3 = t1; // copy assignment
return 0;
}

 
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: