“error:Expected a type,got'classname'"在C ++中 [英] "error: Expected a type, got 'classname'" in C++

查看:796
本文介绍了“error:Expected a type,got'classname'"在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

在指示的行上。

推荐答案

节点

vector<node<int> > vertices;

int 你应该使用你实际需要的类型)

(int is used as an example; you should use the type you actually need)

这篇关于“error:Expected a type,got'classname'&quot;在C ++中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆