I’m looking for some best practice advice. If you have a class declared in C++ like so:
class Foo {
public:
enum { A, B, MAX};
};
Should the enum be accessed like:
Foo::A
or
Foo *var;
var->A;
Up until today I had always accessed the constant values like Foo::A, rather than through a ptr of the class type. In truth I didn’t even believe it was possible. Has anyone come across when and if each form should be used or should I stick to the tried and tested Foo::A method?
EDIT: made Foo var into Foo *var it was a typo as most people have spotted thanks.
The enum is associated with the class, rather than with instances. So
Foo::Ais better.