运行 ❯
建立您
自己的
网站
×
更改方向
更改主题,深色/浅色
前往 Spaces
#include <iostream> using namespace std; class MyClass { public: // Public access specifier int x; // Public attribute private: // Private access specifier int y; // Private attribute }; int main() { MyClass myObj; myObj.x = 25; // Allowed (x is public) myObj.y = 50; // Not allowed (y is private) return 0; }
在函数 'int main()' 中
第8行:错误:'int MyClass::y' 是私有的
第14行:错误:在此上下文中