#include <iostream>
using namespace std;
class Person
{
string name;
int id;
public:
Person(string name,int id)
{
this->name = name;
this->id = id;
}
void display()
{
cout<<“name :”<<this->name<<“,”<<“id :”<<this->id<<endl;
}
};
int main()
{
Person *p[10];
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
p[i] = new Person(“狗博”, i);
}
for(int i=1;i<=n;i++)
{
p[i]->display();
}
return 0;
}
using namespace std;
class Person
{
string name;
int id;
public:
Person(string name,int id)
{
this->name = name;
this->id = id;
}
void display()
{
cout<<“name :”<<this->name<<“,”<<“id :”<<this->id<<endl;
}
};
int main()
{
Person *p[10];
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
p[i] = new Person(“狗博”, i);
}
for(int i=1;i<=n;i++)
{
p[i]->display();
}
return 0;
}
版权声明:本文为erchouchou原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。