Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. // example: class constructor
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. class Rectangle;
  6.  
  7. int main () {
  8.  
  9. Rectangle rect (3,4);
  10. Rectangle rectb (5,6);
  11. cout << "rect area: " << rect.area() << endl;
  12. cout << "rectb area: " << rectb.area() << endl;
  13. return 0;
  14. }
  15.  
  16. class Rectangle {
  17. int width, height;
  18. public:
  19. Rectangle(int,int);
  20. int area () {return (width*height);}
  21. };
  22. Rectangle::Rectangle (int a, int b) {
  23. width = a;
  24. height = b;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement