#include #include enum CPU_Rank { P1 = 1, P2, P3, P4, P5, P6, P7 }; class CPU { private: CPU_Rank rank; int frequency; float voltage; public: CPU(CPU_Rank r = P1, int f = 100, float v = 2.0) : rank(r), frequency(f), voltage(v) { std::cout << "one CPU is created!" << std::endl; } ~CPU() { std::cout << "one CPU is distoried!" << std::endl; } void display() { std::string rank_str; switch (rank) { case P1: rank_str = "P1"; break; case P2: rank_str = "P2"; break; case P3: rank_str = "P3"; break; case P4: rank_str = "P4"; break; case P5: rank_str = "P5"; break; case P6: rank_str = "P6"; break; case P7: rank_str = "P7"; break; default: rank_str = "Unknown Rank"; } std::cout << "rank: " << rank_str << std::endl; std::cout << "frequency: " << frequency << std::endl; std::cout << "voltage: " << voltage << std::endl; } void run() { std::cout << "CPU is running!" << std::endl; } void stop() { std::cout << "CPU stop!" << std::endl; } }; int main() { int rank_input, frequency_input; float voltage_input; std::cin >> rank_input >> frequency_input >> voltage_input; CPU myCPU(static_cast(rank_input), frequency_input, voltage_input); myCPU.run(); myCPU.display(); myCPU.stop(); return 0; }