Modifying and Getting enums from other classes?! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Modifying and Getting enums from other classes?!

I am making a program in c++ were I have made a private enum in a separate class file and I need to modify the value of it from another class which is friend to the other. I tried to make an object and do like: Obj.value = STOP or Obj.value = START but it does not work. What can I do?

18th Mar 2018, 11:07 AM
xaralampis_ - avatar
2 Answers
+ 4
To access the enum values, you need to scope the values inside the member functions of class Input. Eg : void Logic::Input() { input.MState = Moving::START; } It seems enums are treated like static objects inside a class.
18th Mar 2018, 11:43 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 1
Thank you again
18th Mar 2018, 11:44 AM
xaralampis_ - avatar