Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Rectangle Project.cpp : class constructor
- //
- #include <iostream>
- using namespace std;
- class CRectangle {
- int width, height;
- public:
- CRectangle (int, int);
- int area() {
- return (width*height);
- }
- } rectc(7,8);
- CRectangle::CRectangle (int a, int b) {
- width = a;
- height = b;
- }
- int main() {
- CRectangle rect(3, 4);
- CRectangle rectb(5, 6);
- cout << "rect area: " << rect.area() << endl;
- cout << "rectb area: " << rectb.area() << endl;
- cout << "rectc area: " << rectc.area() << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment