Advertisement
Domerk

Rect

Jan 29th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. //rect.h
  2.  
  3. class Rectangular
  4. {
  5. private:
  6.     int x;
  7.     int y;
  8. public:
  9.     int area();
  10.     void sethw();
  11. };
  12.  
  13. //rect.cpp
  14.  
  15. #include "rect.h"
  16.  
  17. int Rectangular::area()
  18. {
  19.     return x*y;
  20. }
  21.  
  22. void Rectangular::sethw (int h, int w)
  23. {
  24.     x=h;
  25.     y=w;
  26. }
  27.  
  28. //main.cpp
  29.  
  30. #include <iostream>
  31. #include "rect.h"
  32. {
  33.     Rectangular r1, r2;
  34.     r1.sethw (100; 100);
  35.     r2.sethw (20; 30);
  36.  
  37.     std::cout<<"1: "<<r1.area()<<"2: "<<r2.area<<std::endl;
  38.     std::cin.get();
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement