#include "iostream"
#include "vector"
#include "algorithm"
using namespace std;
struct C
{
int a;
vector<int> v;
// 从小到大排
bool operator < (const struct C &c) const
{
return v < c.v;
}
};
int main()
{
C c;
for(int i=0; i<3; i++)
c.v.push_back(i);
c.a = 10;
C d;
d = c;
for(int j=0; j<3; j++)
cout << d.v[j] << " ";
cout << endl << d.a << endl << endl;
C e;
e.v.push_back(2);
e.a = 11;
e = c;
for(j=0; j<3; j++)
cout << d.v[j] << " ";
cout << endl << d.a << endl;
return 0;
}
结构体可直接赋值
最新推荐文章于 2024-08-01 21:15:34 发布