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