Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- //перечисляемый тип enum
- enum PCState
- {
- //это по сути просто константы
- ON,
- OFF,
- SLEEP
- };
- class StateClass
- {
- public:
- //сеттер, принимает константу енума PCState
- void SetState(PCState State)
- {
- this->State = State;
- }
- //геттер
- PCState GetState()
- {
- return State;
- }
- private:
- PCState State = PCState::OFF;
- };
- int main(int argc, char *argv[])
- {
- setlocale(LC_ALL, "Rus");
- srand(time(NULL));
- StateClass st;
- st.SetState(PCState::SLEEP);
- switch(st.GetState())
- {
- case PCState::ON:
- std::cout << "ON" << std::endl;
- break;
- case PCState::OFF:
- std::cout << "OFF" << std::endl;
- break;
- case PCState::SLEEP:
- std::cout << "SLEEP" << std::endl;
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement