Read Data Member of class using construction. find volume with constructor..

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

How to I fix Errors on Messenger ?

Fix the 'Unfortunately, Facebook Messenger has stopped' error Open Settings.  Select the Apps or Apps & notifications option.  T...

Contact form

Name

Email *

Message *

loading...