saving . . . saved multiple inheritance has been deleted. multiple inheritance has been hidden .
multiple inheritance
Title
Question
<span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 12.6px; white-space-collapse: preserve; background-color: rgb(249, 249, 249);">Create a class area and perimeter Find the area and perimeter of a rectangle</span>

Advanced-Cpp More-On-Inheritance 07-08 min 10-20 sec 23-11-23, 7:18 p.m. ANushika_321

Answers:

Here, Rectangle should be a class, and member functions should be area and perimeter.
18-01-24, 11:57 a.m. nags
14-07-25, 1:55 p.m. 240181601025@crescent.education

Login to add comment



#include <iostream>
using namespace std;

class Rectangle {
    double length, width;
public:
    void setData(double l, double w) {
        length = l;
        width = w;
    }
    void Area() {
        cout << "Area: " << length * width << endl;
    }
    void Perimeter() {
        cout << "Perimeter: " << 2 * (length + width) << endl;
    }
};

int main() {
    Rectangle r;
    r.setData(5, 3);
    r.Area();
    r.Perimeter();
    return 0;
}

This will print the area and perimeter of the rectangle.


14-07-25, 12:46 p.m. 240181601063@crescent.education
14-07-25, 1:55 p.m. 240181601025@crescent.education

Login to add comment


Log-in to answer to this question.