You are on page 1of 1

NAME: ALINA WAQAR

REG NUMBER: 4676-FOC/BSCS/F22


COURSE: OOP

PROGRAM:
#include <iostream>
class Shapes;
class Rectangle {
public:
Rectangle() {}
void printShapeInfo(const Shapes& shape);
};
class Circle {
public:
Circle() {}
void printShapeInfo(const Shapes& shape);
};
class Shapes {
private:
double length;
double width;
public:
Shapes(double l, double w) : length(l), width(w) {}
friend class Rectangle;
friend class Circle;
};
void Rectangle::printShapeInfo(const Shapes& shape) {
std::cout << "Rectangle: Length = " << shape.length << ", Width = " <<
shape.width << std::endl;
}
void Circle::printShapeInfo(const Shapes& shape) {
std::cout << "Circle: Length (Radius) = " << shape.length << std::endl;
}
int main() {
Shapes rectangle(5.0, 4.0);
Shapes circle(3.0, 0.0);

Rectangle rectangleFriend;
Circle circleFriend;
rectangleFriend.printShapeInfo(rectangle);
circleFriend.printShapeInfo(circle);

return 0;
}

You might also like