Respuesta :
Using the knowledge in computational language in C++ it is possible to write the code being write a class having two private variables
Writting the code in C++:
#include <iostream>
using namespace std;
class Rectangle { /*create a class named Rectangle*/
private:
float l,b; /*this class has two private variables l and b*/
public:
float getArea(float l, float b) /*this class has one member-function getArea which returns the area of the rectangle*/
{
return l*b; /*return the area of the rectangle*/
}
};
int main () { /*the main function to check the working of our Rectangle class*/
float l,b;
Rectangle r1; /*create an object r1 of Rectangle class*/
cout<<"Enter the length of the rectangle: ";
cin>>l; /*input the length of the rectangle from the user*/
cout<<"Enter the breadth of the rectangle: ";
cin>>b; /*input the breadth of the rectangle from the user*/
cout <<"Area of the rectangle is: "<< r1.getArea(l,b)<<" square units."; /*find the area of the rectangle using the member function of the class*/
return 0;
}
See more about C++ at brainly.com/question/19705654
#SPJ1
