时间:2010-04-24 18:44:54

标签: c++

使用以下代码:

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

我得到了:

 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

在指示的行上。在b_graph使用它之前明确定义了节点 - 我在这做了什么?

1 个答案:

答案 0 :(得分:24)

node不是一个类,它是一个类模板。您需要将其实例化以将其用作vector的元素类型,例如,

vector<node<int> > vertices;

int用作示例;您应该使用实际需要的类型)