定义结构体指针并初始化
#include<iostream>
using namespace std;
struct MM
{
char name[20];
int age;
};
int main()
{
MM *p = new MM;
*p = {"宝贝",18};
MM *pp = new MM{ "哈哈",20 };
cout << p->name <<"\t"<<p->age<< endl;
cout << pp->name << "\t" << pp->age << endl;
while (1);
return 0;
}
#笔经#
using namespace std;
struct MM
{
char name[20];
int age;
};
int main()
{
MM *p = new MM;
*p = {"宝贝",18};
MM *pp = new MM{ "哈哈",20 };
cout << p->name <<"\t"<<p->age<< endl;
cout << pp->name << "\t" << pp->age << endl;
while (1);
return 0;
}
#笔经#