Friday, March 18, 2011

Program for Access Specifier Using OOPs & C++ concept


#include<iostream.h>
#include<conio.h>
class emp
{
Private:                       //Access Specifier
char name[20];
int roll;
char dept[8];


public:
void getdata()
{
cout<<"Enter the RollNo:";
cin>>roll;
cout<<"\n Enter the Name:";
cin>>name;
cout<<"\n Enter the Dept:";
cin>>dept;
}
void display()
{
cout<<"\nRollNo="<<roll;
cout<<"\n Name="<<name;
cout<<"\n Dept="<<dept;
}
};
void main()
{
emp e;             //object creation
e.getdata();
e.display();
getche();
}

No comments:

Post a Comment