I wrote a File class in File.h. And I wrote Directory class in Directory.h which is include File& vector. Two header has same namespace.
Here is the code:
#include "File.h" #include <vector> class Directory : public File { public: ... private: std::vector<(File&)> files; }; When I try to compile it, it says:
In file included from Directory.cpp:1:0: Directory.h:29:30: error: template argument 1 is invalid std::vector<(File&)> files; ^ Directory.h:29:30: error: template argument 2 is invalid
std::vectorof reference types. The type must be copyable. Any reason why not to usestd::vector<File>?