位于同一文件“foo.h”中的非常简单的代码:
class Xface
{
public:
uint32_t m_tick;
Xface(uint32_t tk)
{
m_tick=tk;
}
}
std::map<uint32_t, Xface*> m;
Xface* tmp;
tmp = new Xface(100); **//Error**
m[1] = tmp; **//Error**
tmp = new Xface(200); **//Error**
m[2] = tmp; **//Error**
错误是错误:“=”标记之前预期的构造函数、析构函数或类型转换对于每一项任务。
C++ 不是脚本语言。您可以在可执行代码块的范围之外声明项目,但不能进行任何处理。尝试将错误代码移至如下函数中:
int main()
{
std::map<uint32_t, Xface*> m;
Xface* tmp;
tmp = new Xface(100); **//Error**
m[1] = tmp; **//Error**
tmp = new Xface(200); **//Error**
m[2] = tmp; **//Error**
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)