Hi guys,
I'm trying to figure out why this piece of code, while simple, just refuses to compile in Visual C++ 2010. I have these three example files (two headers, and one main CPP code file). I'd like to use an enum defined in one of the header files (main.h) as a return type for a function in the other (foo.h).
main.h:
foo.h:Code:#ifndef __MAINHEAD #define __MAINHEAD #include "foo.h" class main { public: enum aNewEnum {red, white, blue}; }; #endif
main.cpp:Code:#ifndef __FOOHEAD #define __FOOHEAD #include "main.h" class foo { public: main::aNewEnum FunkyFunction(); }; #endif
When I try to build the project, I get error C2653: 'main' : is not a class or namespace name...Code:#include <iostream> #include <string> #include "main.h" int main() { std::cout << "hello world"; return 0; }
I don't think the problem is due to main.cpp, or any of the files for that matter. I feel this should work, but isn't because of something the compiler is missing. Can anyone shed some light on this?



LinkBack URL
About LinkBacks


