Friday, March 18, 2011

Program for Access Specifier Using OOPs & C++ concept Example - 2


#include<iostream.h>
#include<conio.h>
class cube
{


                   public:


                        double side;


                        double volume()


                        {


                                    return(side*side*side);


                        }


};


void main()


{


            cube c1,c2;


            cout << "Enter the lenght of the cube" << endl;


            cin >> c1.side;


            cout << "The volume of the cube is : " << c1.volume() << endl;


            c2.side=c1.side +2;


            cout << "The volume of the second cube is : " << c2.volume() << endl;
}

No comments:

Post a Comment