fork download
  1. // your code goes here
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5.  
  6. class MyClass {
  7. private:
  8. int x=11;
  9. public:
  10. int getX() {
  11. return x;
  12. }
  13.  
  14. void setX(int val) {
  15. x = val;
  16. }
  17. };
  18.  
  19. int main() {
  20. MyClass obj;
  21. cout<<obj.getX()<<endl;
  22. obj.setX(4);
  23. cout<<obj.getX()<<endl;
  24. obj.setX(6);
  25. cout<<obj.getX()<<endl;
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
11
4
6