#include<iostream>
#include<cstring>
using namespace std;
class Employee
{
char name[5];
int id;
int age;
public:
Employee(char* a, int b, int c)
{
strcpy(name, a);
id=b;
age=c;
}
};
class Officer: public Employee
{
char officer_cadre[3];
public:
Officer(char* a, int b, int c, char* d):Employee(char* a, int b, int c)
{
strcpy(officer_cadre, d);
}
};
int main()
{
Officer o1("Nakul", 1, 2, "ABC");
return 0;
}
上面的代码很简单,但我无法弄清楚为什么编译器会抛出错误,例如“预期的 char 之前的主表达式”和“预期的 int 之前的主表达式”。