Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //rect.h
- class Rectangular
- {
- private:
- int x;
- int y;
- public:
- int area();
- void sethw();
- };
- //rect.cpp
- #include "rect.h"
- int Rectangular::area()
- {
- return x*y;
- }
- void Rectangular::sethw (int h, int w)
- {
- x=h;
- y=w;
- }
- //main.cpp
- #include <iostream>
- #include "rect.h"
- {
- Rectangular r1, r2;
- r1.sethw (100; 100);
- r2.sethw (20; 30);
- std::cout<<"1: "<<r1.area()<<"2: "<<r2.area<<std::endl;
- std::cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement