(C++) Cannot refer to an enum class inside a namespace -


hello met problem during project, have this:

types.h

namespace machine {     enum class size{         tiny,         small,         medium     }     //other stuff..... 

and in file:

test.h:

#include "types.h" class sample{     public:         void some_function();         machine::size s; //this declaration correct } 

test.cpp:

#include "test.h" void some_function(){     s = machine::size::tiny;//line aaaa; line error } 

at line aaaa kept getting error message:

error: 'machine::size' not class or namespace

anyone have idea why? or not put enum class inside namespace? thanks!

edit: fixed machine spell problem in first file, sorry that

machine::size s place hold attribute (the size of machine), don't think it's special.

in test.cpp replace definition starting with

void some_function() 

by

void sample::some_function() 

as otherwise defining free standing function no relation whatsoever class sample (in other words, not defining member function). in case s not seen member variable of class sample, hence error.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -