#include <iostream>
#include <string>
using namespace std;
class Person{
public:
Person(string n, int a, string g) {
setName(n);
setAge(a);
setGender(g);
}
void setName(string x) {
name = x;
}
void setAge(int x) {
age = x;
}
void setGender(string x) {
gender = x;
}
get() {
return "\nName: " + name + "\nAge: " + age + "\nGender: " + gender + "\n";
}
private:
string name;
int age;
string gender;
};
int main() {
return 0;
}
那是我的代码,我想做的就是用构造函数创建一个基本类,其中包含定义名称、年龄和性别的三个参数,出于某种原因,当我尝试运行它以检查一切是否正常时,我得到一个错误说明(第 23 行):不匹配的类型 'const __gnu_cxx::__normal_iterator.
有人可以通过修复我的代码来帮忙吗?我真的不明白我做错了什么,提前谢谢!