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'm getting:
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
On the indicated line. Node is clearly defined before b_graph which uses it - what have I done here?
node
is not a class, it's a class template. You need to instantiate it to use it as the element type of vector
, e.g.,
vector<node<int> > vertices;
(int
is used as an example; you should use the type you actually need)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With