//Program to demonstrate Class and Object in C++
#include <iostream.h>
#include <conio.h>
class Box
{
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};
int main( )
{
clrscr();
Box Box1; // Declare Box1 of type Box
double volume; // Store the volume of a box here
// box1 specification
Box1.height = 5.0;
Box1.length = 6.0;
Box1.breadth = 7.0;
// volume of box 1
volume = Box1.height * Box1.length * Box1.breadth;
cout << "Volume of Box1 : " << volume <<endl;
getch();
return 0;
}
#include <conio.h>
class Box
{
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};
int main( )
{
clrscr();
Box Box1; // Declare Box1 of type Box
double volume; // Store the volume of a box here
// box1 specification
Box1.height = 5.0;
Box1.length = 6.0;
Box1.breadth = 7.0;
// volume of box 1
volume = Box1.height * Box1.length * Box1.breadth;
cout << "Volume of Box1 : " << volume <<endl;
getch();
return 0;
}
Post a Comment