Find the volume of Box using construcor ..
image is taken ffom another website
#include<iostream>
#include<conio.h>
using namespace std;
class Box
{
private:
float l,b,h;
public:
Box(float le, float br, float he)
{
l=le;
b=br;
h=he;
}
float getvolume()
{
return(l*b*h);
}
};
int main(){
float vol;
Box ob(10,3.5,5.5);
vol=ob.getvolume();
cout<<"The volume of Box is:"<<vol;
return 0;
getch();
};
No comments:
Post a Comment