執行 ❯
建立您
自己的
網站
×
更改方向
更改主題,深色/淺色
前往 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行:錯誤:在此上下文中