你看看这个行不行
/*/定义一个“电脑”类CComputer,至少添加4个成员变量和4个公有成员函数。
要求:(1)通过构造函数来初始化所有成员变量,函数参数要有缺省值;
(2)再添加1个静态成员变量,用于统计该类一共生成了多少个对象数;
(3)再添加1个私有成员函数,该私有成员函数必须被某个公有函数调用。
要求添加的成员必须要有意义,而且命名要见名知意;添加主函数测试设计的功能
/*/
#include
#include
using namespace std;
class CComputer
{
private:
char brand[18];
char color[10];
int price;
int disk;
int getdisk(){
return disk;
}
public:
static int count;
CComputer(){strcpy(brand,""); strcpy(color,""); price=0; disk=0;}
CComputer(char b[],char c[],int pr,int d):price(pr),disk(d){
strcpy(brand,b);
strcpy(color,c);
count++;
}
void set(char [],char [],int ,int );
void show();
~CComputer(){ count--; }
};
int CComputer::count=0;
void CComputer::set(char b[],char c[],int pr,int d)
{
price=pr;
disk=d;
strcpy(brand,b);
strcpy(color,c);
count++;
}
void CComputer::show()
{
cout<<"Information of the computer:"<
int main()
{
CComputer p1("lenovo","black",5200,500),p2;
p2.set("asus","blue",5000,500);
p1.show();
p2.show();
cout<<"Number of the computer: "<
}