`#include
using namespace std;
include
class Phone
{
public:
Phone(string pName)
{
m_PName = pName;
}
string m_PName;
};
class Person
{
public:
Person(string name, string pName) :m_Name(name),m_Phone(pName){}
string m_Name;
Phone m_Phone;
};
void test01()
{
Person p("张三","苹果 ");
cout << p.m_Name << "用的手机是" << p.m_Phone.m_PName << endl;
}
int main()
{
test01();
return 0;
}`
标签:string,Person,对象,成员,Phone,pName,做类,test01,Name From: https://www.cnblogs.com/tjm1017/p/18118325