Files
CPP/OOP/access_specifier/ex1.cpp
2025-04-29 21:21:54 +02:00

24 lines
438 B
C++

#include <iostream>
using namespace std;
class MyClass {
public:
int x;
private:
int y;
};
int main() {
MyClass classObject;
/*
Here we try to access the y variable ;
But that is not accessible to us cause its a private Value ;
If that y were accessed inside of that function everything would be fine!
*/
classObject.x = 25;
classObject.y = 50;
return 0;
}