Advertisement
lordasif

static class2

Mar 31st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. class myclass
  5. {
  6. public:
  7. static int x;
  8. int y;
  9. void setx(int n)
  10. {x = n; }
  11. void sety(int n)
  12. {y = n; }
  13. int getx()
  14. {return x; }
  15. int gety()
  16. {return y; }
  17. };
  18. int myclass:: x;
  19.  
  20. int main()
  21. {
  22. myclass o1, o2;
  23. myclass:: x = 7;
  24. o1.sety(16);
  25. o2.sety(14);
  26. cout<< o1.getx() << o1.gety()<<endl;;
  27. cout<< o2.getx() << o2.gety();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement