关于C++error C2664错误,谁能帮忙解决一下?谢谢

#include<iostream>usingnamespacestd;enumCPU_Rank{P1=1,P2,P3,P4,P5,P6,P7};classCPU{pub... #include <iostream>
using namespace std;
enum CPU_Rank{P1=1,P2,P3,P4,P5,P6,P7};
class CPU
{
public:
CPU(CPU_Rank r,int f,double v)
{rank=r;
frequency=f;
voltage=v;}
~CPU(){}
void run()
{cout<<"the cpu is running"<<endl;}
void stop()
{cout<<"the cpu is stop"<<endl;}
private:
CPU_Rank rank;
int frequency;
float voltage;
};

class RAM
{private:
int rank;
int size;
public:
RAM(int r,int s)
{rank=r;
size=s;}
void run(){cout<<"the RAM is running"<<endl;}
void stop(){cout<<"the RAM is stop"<<endl;}
};
class CDROM
{private:
int rank;
int size;
public:
CDROM(int r,int s)
{rank=r;
size=s;}
void run(){cout<<"the CDROM is running"<<endl;}
void stop(){cout<<"the CDROM is stop"<<endl;}
};
class RAM;
class CDROM;
class CPU;
class Computer
{private:
CPU cpu;
RAM ram;
CDROM cdrom;
public:
Computer(CPU c,CDROM d,RAM r):cpu(c),cdrom(d),ram(r)
{}
void run()
{cout<<"The computer is running"<<endl;
cpu.run();
cdrom.run();
ram.run();}
void stop()
{cout<<"The computer is stop"<<endl;
cpu.stop();
cdrom.stop();
ram.stop();}
};
void main()
{enum CPU_Rank rank;
rank=P1;
CPU cpu1(rank,1024,3.6);
RAM ram(5,1024);
CDROM cdrom(5,1024);
Computer cp(cpu1,ram,cdrom);
cp.run();
cp.stop();
}

应该如何修改~~
问题为 2、声明一个Computer类,有数据成员芯片(cpu)、内存(ram)、光驱(cdrom)等,有两个公有函数run和stop。cpu为CPU类的一个对象,ram为RAM类的一个对象,cdrom为CDROM类的一个对象,声明并实现这个类。
展开
 我来答
百度网友b598f2a65
推荐于2016-06-04 · 超过18用户采纳过TA的回答
知道答主
回答量:51
采纳率:0%
帮助的人:34.9万
展开全部
#include <iostream>
using namespace std;
enum CPU_Rank{P1=1,P2,P3,P4,P5,P6,P7};
class CPU
{
public:
CPU(CPU_Rank r,int f,double v)
{
rank=r;
frequency = f;
voltage= v;
}
~CPU(){}
void run()
{cout<<"the cpu is running"<<endl;}
void stop()
{cout<<"the cpu is stop"<<endl;}
private:
CPU_Rank rank;
int frequency;
double voltage; // 原: float voltage
};

class RAM
{private:
int rank;
int size;
public:
RAM(int r,int s)
{rank=r;
size=s;}
void run(){cout<<"the RAM is running"<<endl;}
void stop(){cout<<"the RAM is stop"<<endl;}
};
class CDROM
{private:
int rank;
int size;
public:
CDROM(int r,int s)
{rank=r;
size=s;}
void run(){cout<<"the CDROM is running"<<endl;}
void stop(){cout<<"the CDROM is stop"<<endl;}
};
class RAM;
class CDROM;
class CPU;
class Computer
{private:
CPU cpu;
RAM ram;
CDROM cdrom;
public:
Computer(CPU c,CDROM d,RAM r):cpu(c),cdrom(d),ram(r)
{}
void run()
{cout<<"The computer is running"<<endl;
cpu.run();
cdrom.run();
ram.run();}
void stop()
{cout<<"The computer is stop"<<endl;
cpu.stop();
cdrom.stop();
ram.stop();}
};
void main()
{enum CPU_Rank rank;
rank=P1;
CPU cpu1(rank,1024,3.6);
RAM ram(5,1024);
CDROM cdrom(5,1024);
Computer cp(cpu1,cdrom, ram);// 原:Computer cp(cpu1, ram, cdrom);
cp.run();
cp.stop();
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式