fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Rectangle {
  5. int width, height;
  6. public:
  7. void set_values (int,int);
  8. int area () {return width*height;}
  9. };
  10.  
  11. void Rectangle::set_values (int x, int y) {
  12. width = x;
  13. height = y;
  14. }
  15.  
  16. int main () {
  17. Rectangle rect, rectb;
  18. cout<<"rect.area: "<<rect.area()<<endl;
  19. rect.set_values (3,4);
  20. rectb.set_values (5,6);
  21. cout << "rect area: " << rect.area() << endl;
  22. cout << "rectb area: " << rectb.area() << endl;
  23. return 0;
  24. }
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
rect.area: 0
rect area: 12
rectb area: 30