小问题:
这是班级:
class Author
{
Author(const std::string& name, const std::string& email, Gender gender);
Author& setName(const std::string& name);
private:
std::string a_name;
std::string a_email;
int a_gender;
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,他写下一个错误:
错误:'Author :: Author(const string&,const string&,Gender)'是私有的|
但它是拙劣的构造者,所以什么是他的女贞,所以他不能得到呐喊?
坦克!
在访问class默认private:,没有public:.
这个:
class Author
{
Author(const std::string& name, const std::string& email, Gender gender);
Author& setName(const std::string& name);
Run Code Online (Sandbox Code Playgroud)
应该:
class Author
{
public:
Author(const std::string& name, const std::string& email, Gender gender);
Author& setName(const std::string& name);
Run Code Online (Sandbox Code Playgroud)