不知道哪里出错了
#include
#include
using namespace std;
class Animal{
private:
string a;
int b;
string c;
string d;
Animal(string name, int age, string color, string feature){
a = name;
b = age;
c = color;
d = feature;
}
public:
void show(){
cout << "我是一只" << a << "的" << b << ",今年" << c << "岁了,我能" << d << "。" << endl;
}
};
int main()
{
string name;
int age;
string color;
string feature;
cin >> name >> age >> color >> feature;
Animal obj(name, age, color, feature);
obj.show();
return 0;
}
报错内容为[Error] 'Animal::Animal(std::string, int, std::string, std::string)' is private within this context
11行前面加个public:
否则构造函数也是私有函数了啊