c++初始化列表写在类外该如何声明
class Person
{
public:
//初始化列表声明
Person(string name, Phone phone);
string m_Name;
Phone m_Phone;
};
Person::Person(string name, Phone phone) : m_Name(name), m_Phone(phone)
{
cout << "Person类的初始化列表函数" << endl;
}
class Person
{
public:
//初始化列表声明
Person(string name, Phone phone);
string m_Name;
Phone m_Phone;
};
Person::Person(string name, Phone phone) : m_Name(name), m_Phone(phone)
{
cout << "Person类的初始化列表函数" << endl;
}