注册 登录
编程论坛 C++教室

默认实参不在形参列表的结尾 ; 缺少参数 5 的默认参数 ; 未定义标识符??

Onesaber 发布于 2013-06-03 12:35, 3305 次点击
程序代码:
#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 );
}





错误    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"
3 回复
#2
lzj125302013-06-03 12:49
字符串要加双引号
#3
lzj125302013-06-03 12:53
而且第一个和第二个参数之间的逗号错了,因此参数错位了

[ 本帖最后由 lzj12530 于 2013-6-3 13:03 编辑 ]
#4
Onesaber2013-06-03 14:20
回复 3楼 lzj12530
多谢~我太马虎了
1