City Suvidha...your one stop Search

C++ Programs

Go Back to List

Program to use a private data member.

 


#include<iostream.h>
#include<conio.h>


class box
{
private:
int l;
int b;
int h;
public:
void getdata()
{
cout<<"Enter parameters:";
cin>>l>>b>>h;
}

void vol()
{
cout<<"vol is:"<<l*b*h;
}
};


void main()
{
box b1;
b1.getdata();        // function of a class can use a private data by  dot membership operator
b1.vol();
getch();
}

Output:


Enter parameters:10
10
10
vol is:1000


 

If any of you want  to submit your programs and contribute to site please mail us at:

citysuvidha@gmail.com

  Click here to have a look at  List of programs

You can download all the programs in a zip file also. For this you have to do one thing. Just register at the citysuvidha forum  and start any thread of any topic.  Once you start the thread and put your request, admin will automatically send you the desired zip file.