-6

在 C++ 中我得到这两个错误

undefined reference to 'Employee::Employee'
warning: deprecated conversion from string constant to 'char*'

在我的代码的以下两部分中。我知道有很多关于此的主题,但我无法自己解决它....我必须做些什么来解决这个问题?

1.

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];
} 

2.

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;
} 
4

1 回答 1

4

要调用new Employee[count],您需要一个Employee默认构造函数 ( Employee::Employee())。

Employee::Employee(SymbolStr sstr, int* egn, int* cd)不是默认构造函数。

于 2013-01-17T23:52:14.977 回答