这是一个C++程序显示我的功能不超出范围。有人可以告诉我错误以及如何解决这些错误

发布于 2025-01-20 14:29:13 字数 1488 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

装纯掩盖桑 2025-01-27 14:29:13

您创建一个 Student 实例 z,并调用 Misc。该实例上的 setter 成员函数。然后,当您调用函数来打印您设置的某些值时,您忘记告诉编译器要打印哪个实例的值。由于您只有一个实例 z,因此请在成员函数之前添加该实例:

    z.get_age();
    z.to_string();
    z.get_std();

改进建议:不返回值但打印该值的函数最好命名为 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:

    z.get_age();
    z.to_string();
    z.get_std();

Improvement suggestion: Functions that does not return a value but that prints the value would be better named print-something rather than get-something.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文