C++多线程编程实战书本练习,为什么10报错?


#include 

using namespace std;

class CPerson
{
public:
    CPerson(int iAge, char* sName)
    {
        this->iAge = iAge;
        strcpy_s(this->sName, 32, sName);
    }
    virtual char* WhoAmI()
    {
        return a;
    }

private:
    int iAge;
    char sName[32];
    char a[20]{ "I am a person" };
};

class CWorker :public CPerson
{
public:
    CWorker(int iAge, char* sName, char* sEmploymentStatus) : CPerson(iAge, sName)
    {
        strcpy_s(this->sEmploymentStatus, 32, sEmploymentStatus);
    }
    virtual char* WhoAmI()
    {
        return a;
    }
private:
    char sEmploymentStatus[32];
    char a[20]{ "I am a worker" };
};

class CStudent :public CPerson
{
public:
    CStudent(int iAge, char* sName, char* sStudentIdentityCard) :CPerson(iAge, sName)
    {
        strcpy_s(this->sStudentIdentityCard, 32, sStudentIdentityCard);
    }
    virtual char* WhoAmI()
    {
        return a;
    }
private:
    char sStudentIdentityCard[32];
    char a[20]{ "I am a student" };
};

int main()
{
    CPerson cPerson(10, "John");
    cout << cPerson.WhoAmI() << endl;

    CWorker cWorker(35, "Marry", "On wacation");
    cout << cWorker.WhoAmI() << endl;

    CStudent cStudent(22, "Sanfra", "Phisician");
    cout << cStudent.WhoAmI() << endl;

}


我在C++多线程编程实战书本学习。正在学习第1章。为什么代码中10报错?

char a[20]{ "I am a person" };
不能这么写
应该是
char a[20] = { "I am a person" };
别的类似