Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 有没有办法在一个getter中返回三个容器?_C++_C++11_Tuples_Getter - Fatal编程技术网

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::tuplegetContainers中;线然而,从一开始,这看起来像是一个相当糟糕的类设计。即使错误已经修复,您也可能会复制大量指针来返回这三个向量。你想达到什么目标?
std::tuple< std::vector<Vehicle*>, std::vector<Client*>, std::vector<Rental*>>