C++ vector 当元素为对象时,按条件查询数据
在类中,创建好get_XXX函数,用于提取对象数据,再使用迭代器遍历符合条件的对象
#include <iostream>
#include <vector>
using namespace std;
/*
* 创建汽车类
* */
class Car {
public:
//类成员属性
string number;//车牌号
string type;//车辆类型
string owner;//所有人
string address;//地址
string use;//使用性质
string model;//品牌型号
public:
/*
* Car类构造函数
* */
Car(string number,string type,string owner,string address,string use,string model) {
this->number = number;
this->type = type;
this->owner = owner;
this->address = address;