一个类的问题
#include<iostream>using namespace std;
enum CPU_Rank{P1=1,P2,P3,P4,P5,P6,P7};
class CPU
{
public:
CUP(CPU_Rank r,int f,float v)
{
rank=r;
frequency=f;
voltage=v;
cout<<"等级为:"<<rank<<"频率为:"<<frequency<<"电压为:"<<voltage<<"的CPU构造成功!!!!"<<endl;
}
~CPU(){cout<<"CPU析构成功!!!!!"<<endl;}
void run(){cout<<"CPU正在运行"<<endl;}
void stop(){cout<<"CPU运行停止"<<endl;}
private:
CPU_Rank rank;
int frequency;
float voltage;
};
int main()
{
CPU a(P2,250,2.1);
a.run();
a.stop();
return 0;
}
运行出现下面错误:
G:\编程文件夹\c++\实训\4\lab4_1.cpp(24) : error C2661: 'CPU::CPU' : no overloaded function takes 3 parameters
是怎么回事???改了几下还是不行,帮下忙