我在使用 g++ 时不断收到此错误。
这是有问题的代码行:
Register register = new Register(til_amt, num_ones);
这是标题定义:
Register(int, int);
这是实现定义:
Register::Register(int amt, int ones)
{
init();
til_amt += amt;
num_ones += ones;
}
init() 函数是内联定义的,只是将字段设置为 0。我已将问题隔离到这些代码行,并且我在 stackoverflow/google 上进行了全面搜索,但似乎无法解决问题.我什至尝试将对象实例化分成两行,但这也没有用。
最佳答案
register
是关键字。它不能用作变量。
来自 C++ 标准:
7.1.1 Storage class specifiers [dcl.stc]
1 The storage class specifiers are
storage-class-specifier:register
static
thread_local
extern
mutable
关于c++ - 错误 :expected unqualified-id before '=' token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34101691/