by Dinesh Thakur Category: Classes in C++

#include <iostream.h>

#include<conio.h>

class box

{

double line,width,heigth;

double volume;

public:

box(double a,double b,double c);

void vol();

};

box::box(double a,double b,double c)

{

line=a;

width=b;

heigth=c;

volume=line*heigth;

}

void box::vol()

{

Cout<<"Volume is:" <<volume<<''\n'';

}

void main()

{

box x(3.4,4.5,8.5),y(2.0,4.0,6.0);

x.voI();

y.voI();

getch();

}

 

Output:

Volume is: 28.9

Volume is: 12



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article