error C2146:missing 'token' before identifier 'identifier'

2000mylove 2003-11-16 05:12:19
在 一个类里面用另一个类的时候
经常同时出现那三个错误
error C2146:missing 'token' before identifier 'identifier'
error C2501:missing storage-class and ...

有时候变变#include "MyClass.h"的位置就好了
有时候就用 //注释掉调用类的地方
有时候一点办法都没有
有时候我放它一会儿就好了

大家有没有什么完整的解决方案啊,这种问题真象牙疼
疼起来要命
...全文
127 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
DarthVader 2003-11-19
  • 打赏
  • 举报
回复
哈哈 那么只有看代码咯
2000mylove 2003-11-19
  • 打赏
  • 举报
回复
是啊,大侠,上面MSDN里面的文章我看了
可是没用啊,它说的那两个原因都不是
第一个 说拼写错误,我都瞪了好几眼啦
第二个 说类没有定义,可我用的是从基类派生过来的啊,这种用法太常见了,其他程序用的好好的啊,就是派生一个类,然后包含,就可以在自己的类里面用了
2000mylove 2003-11-19
  • 打赏
  • 举报
回复
看什么代码啊
DarthVader 2003-11-18
  • 打赏
  • 举报
回复
如果#include "MyClass.h"放的位置不当,有可能导致MyClass中的某些变量类型未知,不过最好还是多贴一些源码出来看看
DarthVader 2003-11-18
  • 打赏
  • 举报
回复
syntax error : missing 'token' before identifier 'identifier'
The compiler expected token and found identifier instead.

Probable cause
A typographical error. Error C2065 usually precedes this error.
The following sample generates C2146:

// C2146.cpp
int main()
{
intt x; // C2146 : missing semicolon before 'x'
}

================================================================
'identifier' : missing storage-class or type specifiers

The identifier is declared without specifying its type.

Possible causes

Spelling or capitalization error.
Missing type specifier in the declaration of the identifier.
Example

// C2501.cpp
// Header file for the CUndeclared has been omitted:
class CMyClass {
private:
CUndeclared m_myClass; // C2501: Class unknown
} ;


8,304

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧