Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. // classes example
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. class Rectangle {
  6. // instance variables
  7. int width, height;
  8. public:
  9. void set_values (int,int);
  10. int area() {return width*height;}
  11. };
  12.  
  13. void Rectangle::set_values (int x, int y) {
  14. width = x;
  15. height = y;
  16. }
  17.  
  18. int main () {
  19. Rectangle rect;
  20. rect.set_values (3,4);
  21. cout << "area: " << rect.area();
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement