Create a class Box and initialized its object using operator overloading. Calculate area,volume of the box using suitable member function.
Answers
Answered by
0
Not understanding plz
Answered by
0
Answer:
#include <iostream>
using namespace std;
class box
{
private:
int area,volume,height,width,length;
public:
void operator ++()
{
height=10;
width=20;
length=20;
}
void Area(){ cout<<"area is"<<2*(height*width+height*length+width*length); }
void Volume() { cout<<"Volume is "<<height*width*length; }
};
int main()
{
box t;
// this calls "function void operator ++()" function
++t;
t.Area();
t.Volume();
return 0;
}
Explanation:
here operator "++ "overloading is used to just initialize the height width and length its called at ++t and the other member functions are doing their own job as said area and volume.
Similar questions