【发布时间】:2013-09-30 14:40:45
【问题描述】:
#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.
有人可以帮忙修复我的代码吗?我真的不明白我做错了什么,提前谢谢!
【问题讨论】:
-
你能指出哪一行是第23行吗?谢谢。