This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
您创建一个
Student
实例z
,并调用 Misc。该实例上的 setter 成员函数。然后,当您调用函数来打印您设置的某些值时,您忘记告诉编译器要打印哪个实例的值。由于您只有一个实例z
,因此请在成员函数之前添加该实例:改进建议:不返回值但打印该值的函数最好命名为
print
-something 而不是get
-something。You create one
Student
instance,z
, and call misc. setter member functions on that instance. When you then call the functions to print some of the values you've set, you forgot to tell the compiler which instance you want to print the values for. Since you only have one instance,z
, add that before the member functions:Improvement suggestion: Functions that does not return a value but that prints the value would be better named
print
-something rather thanget
-something.