请问这段程序有什么问题呀?谢谢!
#include<iostream>
#include<string>
using namespace std;
class People
{
public:
void display()
{
cout<<"姓名:"<<name<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"年龄:"<<age<<endl;
}
private:
string name;
string sex;
int age;
};
People::People(string n,string s,int a)
{
name=n;
sex=s;
age=a;
}
int main()
{
People p1("张宏宇","男",21);
p1.display();
return 0;
}
为什么编译不能通过呢?错误指向People::People(string n,string s,int a)这一行