Advertisement
raju02

C++ this pointer

Nov 10th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. ///This pointer
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. class fun{
  5. private:
  6. int a , b;
  7. public:
  8. void set (int a , int b)
  9. {
  10. this -> a = a;
  11. this -> b = b;
  12. }
  13. int area ()
  14. {
  15. return a * b;
  16. }
  17. };
  18. int main()
  19. {
  20. fun obj;
  21.  
  22. obj.set(1 ,2);
  23.  
  24. cout<<obj.area();
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement