Previously I've defined enumerated types that are intended to be private in the header file of the class.
private:
enum foo { a, b, c };
However, I don't want the details of the enum exposed anymore. Is defining the enum in the implementation similar to defining class invariants?
const int ClassA::bar = 3;
enum ClassA::foo { a, b, c };
I'm wondering if this the correct syntax.
C++ doesn't have forward declarations of enums, so you can't separate enum "type" from enum "implementation".
The following will be possible in C++0x:
// foo.h
class foo {
enum bar : int; // must specify base type
bar x; // can use the type itself, members still inaccessible
};
// foo.cpp
enum foo::bar : int { baz }; // specify members
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With