您的位置:首页 > 编程语言 > C语言/C++

c++

2016-07-24 08:59 363 查看

include

include

include

using namespace std;

class U{

public:

unsigned long id;

U() :id(0){}

//这里有两个构造函数,一个类可以有好几个构造函数,就是构造函数的重载

U(unsigned long x) :id(x){}

};

bool operator==(const U& x, const U& y)

{

return x.id == y.id;

}

bool operator!=(const U& x, const U& y)

{

return x.id != y.id;

}

int main() {

cout << “zhengmingjiandan de xiangliang gouzhao hanshu” << endl;

vector vector1, vector2(3);

assert(vector1.size() == 0);

assert(vector2.size() == 3);

//比较vector里面的值

assert(vector2[0] == U() && vector2[1] == U() && vector2[2] == U());

//vector = vector

//T0跟T1不一样就不行

//assert(vector2 = vector(3, U()));//赋值运算,vector和vector[u]类型不一样哎

cout << “—OK.” << endl;

getchar();

return 0;
[/u]

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