我有這個類:無法從「初始清單」轉換爲UserController的
class UserController
{
private:
Repo repo;
Repo adoption;
public:
UserController(const Repo& r, const Repo& a) : repo(r), adoption(a) {}
Dog get(int index) { return this->repo.get(index); };
};
當我嘗試創建類型UserController中的對象,像這樣:
UserController controller{ repo1, repo2 };
它給了我錯誤:「錯誤C2440:'初始化':無法從'初始化列表'轉換爲'UserController'」。爲什麼?
你用C++ 11打開了嗎? – NathanOliver