您好我有文件名爲MyCode.h和MyCode.cpp我的枚舉是不是類或命名空間
在MyCode.h我在MyCode.cpp宣佈
enum MyEnum {Something = 0, SomethingElse = 1};
class MyClass {
MyEnum enumInstance;
void Foo();
};
然後:
#include "MyCode.h"
void MyClass::Foo() {
enumInstance = MyEnum::SomethingElse;
}
但相剋編譯時++我得到的錯誤「MyEnum」不是一個類或命名空間...
(在MS VS2010但不能正常工作linux g ++)
任何想法? 謝謝 Thomas
注:在你的'.cpp'文件,如果你想爲'MyClass的:: foo'實施中,簽名會'MyClass的無效:: Foo(){...}'。你錯過了'MyClass ::'位。 – phooji 2011-03-04 01:12:21
MyCode.h!= MyClass.h ...疑問雖然有幫助:P – dcousens 2011-03-04 01:37:24