【问题标题】:Errors porting Win code to Linux [duplicate]将 Win 代码移植到 Linux 时出错 [重复]
【发布时间】:2012-11-22 00:13:15
【问题描述】:

可能重复:
Where and why do I have to put the “template” and “typename” keywords?
declaring a C++ set iterator

我正在尝试在 Linux 系统中编译 C++ 一些代码,这些代码在 Windows 中运行良好。

我遇到了很多类似以下的错误:

code:
..
39          set<Node<T>*>::iterator child;
...

g++ 给了我错误:

Node.h:39: error: expected ‘;’ before ‘child’

这只是一个例子。你能给我一些解决方法的提示吗?

【问题讨论】:

  • 可能是编码或windows换行问题

标签: c++ linux porting


【解决方案1】:

你必须写

typename set<Node<T>*>::iterator child;

事实上,编译器并不知道iterator 是在templated 类set 中定义的type 的名称。你必须明确地告诉它。

Visual Studio 允许这是隐式的。 gcc 没有。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-30
    • 2018-09-28
    • 1970-01-01
    相关资源
    最近更新 更多