c++ - Can I use an enum in a constructor for a class? -


i trying make class , inside of class want define enum called type. can use enum defined constructor class? if so, how access outside of class?

class type { public:   enum ttype { black, white, gray };   type(ttype type, std::string value);   ~type();  ... 

this code doesn't give me errors when try create instance of class in class gives me error because black not defined:

type piece(black, value); 

is there special way , still have ttype class constructor type class? first time using enums don't know how work exactly.

yes can:

type piece(type::black, value); 

enum ttype in scope of class type, have use scope resolution when accessing outside type's body , member functions.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -