![]() |
#2
lzj125302013-06-03 12:49
|

#include<fstream>
using namespace std;
class computer
{
private:
char disk[20],CPU[20],firm[20],type[20];
int price,date;
public:
computer( char *d = new char[20] , char *C = new char[20] , char *f = new char[20], char *t = new char[20],int p,int m)
{
strcpy(disk,d);
strcpy(CPU,C);
strcpy(firm,f);
strcpy(type,t);
price = p;
date = m;
}
void show_disk()
{
cout << disk << endl;
}
void show_CPU()
{
cout << CPU << endl;
}
void show_firm()
{
cout << firm << endl;
}
void show_price()
{
cout << price << endl;
}
void show_date()
{
cout << date << endl;
}
void show_type()
{
cout << type << endl;
}
void show_all()
{
cout << "disk:" << disk << endl << "CPU:" << CPU << endl << "firm:" << firm <<endl << "type:" << type << endl << "price:" << price << endl << "date:" << date << endl;
};
};
void main()
{
computer acer( seagate,interl , china , sa000 , 4999 , 20110411 );
}
using namespace std;
class computer
{
private:
char disk[20],CPU[20],firm[20],type[20];
int price,date;
public:
computer( char *d = new char[20] , char *C = new char[20] , char *f = new char[20], char *t = new char[20],int p,int m)
{
strcpy(disk,d);
strcpy(CPU,C);
strcpy(firm,f);
strcpy(type,t);
price = p;
date = m;
}
void show_disk()
{
cout << disk << endl;
}
void show_CPU()
{
cout << CPU << endl;
}
void show_firm()
{
cout << firm << endl;
}
void show_price()
{
cout << price << endl;
}
void show_date()
{
cout << date << endl;
}
void show_type()
{
cout << type << endl;
}
void show_all()
{
cout << "disk:" << disk << endl << "CPU:" << CPU << endl << "firm:" << firm <<endl << "type:" << type << endl << "price:" << price << endl << "date:" << date << endl;
};
};
void main()
{
computer acer( seagate,interl , china , sa000 , 4999 , 20110411 );
}
错误 1 error C2548: “computer::computer”: 缺少参数 5 的默认参数
错误 2 error C2548: “computer::computer”: 缺少参数 6 的默认参数
错误 3 error C2065: “seagate,interl”: 未声明的标识符
错误 4 error C2065: “china”: 未声明的标识符
错误 5 error C2065: “sa000”: 未声明的标识符
6 IntelliSense: 默认实参不在形参列表的结尾
7 IntelliSense: 未定义标识符 "seagate,interl"
8 IntelliSense: 未定义标识符 "china"
9 IntelliSense: 未定义标识符 "sa000"