#include <string>
#include <iostream>
using namespace std;
struct Person
{
string name;
int age;
};
Person GetPerson();
int main()
{
Person person = GetPerson();
cout << person.name << " "<< person.age << endl;// 输出ganquanfu 24
int wait;
cin >> wait;
return 0;
}
Person GetPerson()
{
Person p;
p.name = "ganquanfu";
p.age = 24;
return p;
}
#include <string>
#include <iostream>
using namespace std;
struct Person
{
string name;
int age;
};
Person *GetPerson();
int main()
{
Person *person = GetPerson();
cout << person->name << " "<< person->age << endl;// 输出乱码
int wait;
cin >> wait;
return 0;
}
Person *GetPerson()
{
Person p;
p.name = "ganquanfu";
p.age = 24;
return &p;
}