#include using namespace std; 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) { cout << "one CPU is created!" << endl; } // 析构函数 ~CPU() { cout << "one CPU is distoried!" << endl; } // 运行 void run() { cout << "CPU is running!" << endl; } // 停止 void stop() { cout << "CPU stop!" << endl; } // 显示CPU信息 void display() const { cout << "rank:P" << rank << endl; cout << "frequency:" << frequency << endl; cout << "voltage:" << voltage << endl; } }; int main() { int f; float v; cin >> f >> v; CPU myCPU(P6, f, v); myCPU.run(); myCPU.display(); myCPU.stop(); return 0; }