"error: Expected type obtained by 'classname'" in C ++
Using the following code:
template <typename T> class node { [. . .] }; class b_graph { friend istream& operator>> (istream& in, b_graph& ingraph); friend ostream& operator<< (ostream& out, b_graph& outgraph); public: [...] private: vector<node> vertices; //This line I get:
error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector' error: expected a type, got 'node' error: template argument 2 is invalid In the specified line. Node is clearly defined before using b_graph - what have I done here?
node not a class, it is a class template. You need to create an instance to use it as a type of vector element, e.g.
vector<node<int> > vertices; Used as an example( int , you should use the type that you really need)