C++;对…的未定义引用。。。同时警告:不推荐将字符串常量转换为';字符*'; 在C++中,我得到了这两个错误 undefined reference to 'Employee::Employee' warning: deprecated conversion from string constant to 'char*'
在我的代码的以下两部分中。我知道有很多关于这个的话题,但我自己解决不了。。。。我要怎么做才能解决这个问题 一,C++;对…的未定义引用。。。同时警告:不推荐将字符串常量转换为';字符*'; 在C++中,我得到了这两个错误 undefined reference to 'Employee::Employee' warning: deprecated conversion from string constant to 'char*',c++,C++,在我的代码的以下两部分中。我知道有很多关于这个的话题,但我自己解决不了。。。。我要怎么做才能解决这个问题 一, Employee::Employee(SymbolStr sstr、int*egn、int*cd) { sbstr=sstr; 对于(int i=0;i
Employee::Employee(SymbolStr sstr、int*egn、int*cd)
{
sbstr=sstr;
对于(int i=0;i<10;i++)
id[i]=egn[i];
对于(int i=0;i<4;i++)
代码[i]=cd[i];
}
二,
intmain()
{
流文件输出(“LuboHW.txt”);
不能计数;
//cin.ignore();
员工*emp=新员工[计数];
for(int i=0;i cout要调用newemployee[count]
您需要一个Employee
默认构造函数(Employee::Employee()
)
Employee::Employee(SymbolStr sstr,int*egn,int*cd)
不是默认的构造函数。您可以做的第一件事是格式化您的问题,使其实际可读。请保留规则“1个问题=1个问题”,好吗?thx对于帮助人员,我现在知道了规则^^我的概念是,您的类缺少默认构造函数,因为您为它定义了一个构造函数,*emp[j].getCode()
是错误的。所有错误都在Visual Studio的“输出”窗口中。“错误”窗口只有摘要。问题在于主员工*emp=新员工[count];我有点不小心切换了它们
Employee::Employee(SymbolStr sstr, int* egn, int* cd)
{
sbstr=sstr;
for(int i = 0; i < 10; i++)
id[i] = egn[i];
for(int i = 0; i < 4; i++)
code[i] = cd[i];
}
int main()
{
ofstream fileout("LuboHW.txt");
cout << "Please, enter how many entries of employee's information would you like to make?" << endl;
int count;
cin >> count;
//cin.ignore();
Employee* emp = new Employee[count];
for(int i = 0; i < count; i++)
{
cout << "Entering information about employee number " << i << ": " << endl;
emp[i].read();
}
cout << "Please, enter the code of the desired employee position: " << endl;
int cd[4];
for(int i = 0; i < 4; i++)
cin >> cd[i];
//cin.ignore();
//writing information about employee in fileout.txt, searching by code
for(int i = 0; i < count; i++)
{
for(int j = 0; j < 4; j++)
{
if(*emp[j].getCode() == cd[i])
continue;
if(j == 3)
fileout << emp[i] << endl;
}
}
system("PAUSE");
return 0;
}