C++ 有没有办法在一个getter中返回三个容器?
我想知道有没有办法一次拿到三个集装箱。 我的课程是:C++ 有没有办法在一个getter中返回三个容器?,c++,c++11,tuples,getter,C++,C++11,Tuples,Getter,我想知道有没有办法一次拿到三个集装箱。 我的课程是: class DataContainer { private: std::vector<Rental*> rentals; std::vector<Vehicle*> vehicles; std::vector<Client*> clients; public: DataContainer(); bool loadObjects(); bool create
class DataContainer
{
private:
std::vector<Rental*> rentals;
std::vector<Vehicle*> vehicles;
std::vector<Client*> clients;
public:
DataContainer();
bool loadObjects();
bool createRentals();
std::string showVehicles() const;
std::string showClients() const;
std::string showDetails() const ;
std::tuple< std::vector<Vehicle*>type1, std::vector<Client*>type2, std::vector<Rental*>type3 > getContainers();
virtual ~DataContainer();
};
我的函数如下所示:
std::tuple< std::vector<Vehicle*>type1, std::vector<Client*>type2, std::vector<Rental*>type3 > DataContainer::getContainers()
{
return std::make_tuple(vehicles,clients,rentals);
}
希望有人能给我一些提示,如果这对我在C++11上的工作有什么影响的话。类型应该是
std::tuple< std::vector<Vehicle*>, std::vector<Client*>, std::vector<Rental*>>
字段名无效
作为元组的替代方法,您可以定义一个包含3个容器的结构类型并返回该类型。std::tuple期望T1、T2、T3为类型。std::vectortype1不是有效的类型。std::vector is.type2等不应位于std::tuple
std::tuple< std::vector<Vehicle*>, std::vector<Client*>, std::vector<Rental*>>