My enum is not a class or namespace
来源:互联网 发布:ps dr3插件for mac 编辑:程序博客网 时间:2024/06/05 09:47
http://stackoverflow.com/questions/5188554/my-enum-is-not-a-class-or-namespace
Hi I have files called MyCode.h and MyCode.cpp
In MyCode.h I have declared
enum MyEnum {Something = 0, SomethingElse = 1};class MyClass {MyEnum enumInstance;void Foo();};
Then in MyCode.cpp:
#include "MyCode.h"void MyClass::Foo() { enumInstance = MyEnum::SomethingElse;}
but when compiling with g++ I get the error 'MyEnum' is not a class or namespace...
(works fine in MS VS2010 but not linux g++)
Any ideas?ThanksThomas
The syntax MyEnum::SomethingElse
is a Microsoft extension. It happens to be one I like, but it's not Standard C++.enum
values are added to the surrounding namespace:
// header enum MyEnum {Something = 0, SomethingElse = 1}; class MyClass { MyEnum enumInstance; void Foo(); } // implementation #include "MyClass.h" void Foo() { enumInstance = SomethingElse; }
0 0
- My enum is not a class or namespace
- is not a class or namespace name
- is not a class or namespace name
- is not a class or namespace name解决方法
- std' : is not a class or namespace name,解决
- error C2653: 'QMessageBox' : is not a class or namespace name
- is not a class or namespace name解决方法
- is not a class or namespace name解决方法
- 【VC】编译出错is not a class or namespace name的解决办法
- 编译错误提示:GetWeb.cpp(99) : error C2653: 'CWebPage' : is not a class or namespace name
- 出现类似'CListView' : is not a class or namespace name的原因及解决方法
- 关于error C2871: 'std' : does not exist or is not a namespace处理
- 关于VC中 error C2871: 'std' : does not exist or is not a namespace
- 关于error C2871: ''std'' : does not exist or is not a namespace处理
- error C2871: 'std' : does not exist or is not a namespace
- C++ 编译出现: error C2871: 'std' : does not exist or is not a namespace 怎么解决
- 关于VC中 error C2871: 'std' : does not exist or is not a namespace
- error C2871: 'std' : does not exist or is not a namespace
- 后端程序员也需要理解的HTTP缓存
- lucene的丰富的各种查询(一)
- 一点一点积累的快捷键
- Hibernate Validator
- 静态链表
- My enum is not a class or namespace
- Java并发编程系列之二十一:CountdownLatch
- 获取设备上的调试信息与崩溃日志分析
- CodeForces - 616A Comparing Two Long Integers (模拟)比较两个数大小
- 数组转集合,集合转数组
- AB是一家?VAO与VBO
- C#目录文件监控
- lucene的丰富的各种查询(二)
- 设计模式之适配器模式