#include <iostream>
using namespace std;
class Rectangle {
private:
double length;
double breadth;
public:
Rectangle(double l, double b) {
length = l;
breadth = b;
}
Rectangle(Rectangle &obj) {
length = obj.length;
breadth = obj.breadth;
}
double calculateArea() {
return length * breadth;
}
};
int main() {
Rectangle obj1(10,6);
Rectangle obj2 = obj1;
cout << "Area of Rectangle 1: " << obj1.calculateArea();
cout << "Area of Rectangle 2: " << obj2.calculateArea();
return 0;
}
No comments:
Post a Comment