fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. class CWin
  6. {
  7. private:
  8. char id;
  9. int width, height;
  10.  
  11. public:
  12. int area()
  13. {
  14. return width*height;
  15. }
  16. void show_area()
  17. {
  18. cout << "window " << id << ", area= " << area() << endl;
  19. }
  20.  
  21. void set_data(const char &i, const int &w, const int &h)
  22. {
  23. id = i;
  24. width = w;
  25. height = h;
  26. }
  27.  
  28. void set_data(const char &i)
  29. {
  30. id = i;
  31. }
  32.  
  33. void set_data(const int &w, const int &h)
  34. {
  35. width = w;
  36. height = h;
  37. }
  38. };
  39.  
  40. int main(void)
  41. {
  42. CWin winA, winB;
  43.  
  44. winA.set_data ('A',50,40);
  45. winB.set_data ('B');
  46. winB.set_data (80,120);
  47.  
  48. winA.show_area();
  49. winB.show_area();
  50.  
  51. system("pause");
  52. return 0;
  53. }
  54.  
  55.  
  56.  
Success #stdin #stdout #stderr 0s 4556KB
stdin
Standard input is empty
stdout
window A, area= 2000
window B, area= 9600
stderr
sh: 1: pause: not found