解决方案1: 如果我有一个类似于,
class car{ public: int a; string b; bool c;};
我可以建立一个包含200辆车的向量:
std::vector<car> allcas;
allcars.resize(200)
在运行时,我只需要执行以下操作:
this_car=allcars[102];
然后....
解决方案2:
我有......
std::vector<int> a; a.resize(200);
std::vector<string>b; b.resize(200);
std::vector<bool> c; c.resize(200);
this_car_a = a[102];
this_car_b = b[102];
this_car_c = c[102];
问题:
哪个更快?
有人有想法吗?提前感谢!