关于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类的一个对象,声明并实现这个类。 展开
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类的一个对象,声明并实现这个类。 展开
1个回答
展开全部
#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();
}
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();
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询