Reputation:
I am working on C++ code trying to build a FlipIt game program. I have a header file and a .cpp file. In the header file I have a flipit class where one of the functions is an enum type function. For example in the header file FlipIt.h:
(enum declaration)
enum Color { clear_ = false, solid_ = true };
(the function)
Color fetch( int row, int col ) const;
(In the FlipIt.cpp file this is what I implemented the function in the class as)
int FlipIt::fetch( int row, int col ) const
When I do this VS2010 says IntelliSense: declaration is incompatible with "FlipIt::Color FlipIt::fetch(int row, int col) const"
What does this mean?
Upvotes: 0
Views: 270
Reputation: 41
You must distinguish the enum type was defined in which namespace.if your enum was just defined in header file, not in cpp file. You include the header file, the linker can find the type of definition, if you define in class, you must add class prefix. The linker can find the definition of the type. So, if your enum type was defined in global area there is no problem. if you define in class, you must use "Class::Type".
Upvotes: 0
Reputation: 13217
It means that your promised returnvalue of FlipIt::Color
in your declaration of your method differs from the type you provide in your implementation. And enum
is not int
.
Try
FlipIt::Color FlipIt::fetch(int row, int col) const { }
for your implementation.
Upvotes: 1
Reputation: 55897
But Color
is not int
. It's enum
and it has some underlying type (that's depends on compiler), but it's another type anyway.
Upvotes: 2