当其他类对象作为本类成员,构造时候先构造类对象,再构造自身
析构的顺序与构造顺序相反
#include
using namespace std;
#include
class phone{
public:
phone(string pname){//手机品牌名,例如华为
m_pname=pname;
cout<<"phone的构造函数调用"<
string m_pname;
};
class person{
public:
person():m_name("张三"),m_phone("华为13"){
cout<<"person的构造函数调用"<
string m_name;
phone m_phone;
};
void test1(){
person p;
cout<
int main(){
test1();
return 0;
}



