fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Rectangle {
  5. int *hp;
  6. int *wp;
  7.  
  8. public:
  9. Rectangle(int _h, int _w);
  10. //~Rectangle();
  11. //int area();
  12. };
  13.  
  14. // LINE-1: define parametrized constructor
  15. Rectangle::Rectangle(int _h,int _w)
  16. {
  17. hp=&_h;
  18. wp=&_w;
  19. cout<<"In PC ";
  20. cout<<*hp<<" "<<*wp<<endl;
  21. }
  22.  
  23.  
  24. // LINE-2: define destructor
  25. /*Rectangle::~Rectangle()
  26. {
  27. }
  28.  
  29. // LINE-3 define function area()
  30. int Rectangle::area()
  31. {
  32.   int p=*hp;
  33.   int q=*wp;
  34.   int area= p*q;
  35.   return area;
  36. }
  37. */
  38. int main()
  39. {
  40. int x, y;
  41. cin >> x >> y;
  42.  
  43. Rectangle r1(x, y);
  44. //cout << r1.area();
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 4576KB
stdin
10 20
stdout
In PC 10 20