AbdulFathaah

class shape C++

Dec 20th, 2023
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. using namespace std;
  4. class shape
  5. {
  6. private : int len,br,h;
  7. public : void read();
  8. void display();
  9. void operator++();
  10. };
  11. void shape :: read()
  12. {
  13. cout<<"Enter value for length breadth height:\n";
  14. cin>>len>>br>>h;
  15. }
  16. void shape :: operator++()
  17. {
  18. len++;
  19. br++;
  20. h++;
  21. }
  22. void shape :: display()
  23. {
  24. cout<<"Length= "<<len<<"\nBreadth= "<<br<<"\nHeight= "<<h;
  25. }
  26. int main()
  27. {
  28. shape s1;
  29. s1.read();
  30. s1.display();
  31. cout<<"\nAfter Incrementing:\n---------------\n";
  32. ++s1;
  33. s1.display();
  34. getch();
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment