Class In C++
A class is an entity in which member variable
and member function are involved so it is called class.
Fig: Class In C++ |
Program:
#include<iostream.h>
#include<conio.h>
class
emp
{
private:
char
name[10];
int
age;
public:
void
get()
{
cout<<”enter
name”<<endl;
cin>>name;
cout<<”enter
age”<<endl;
cin>>age;
}
void
show()
{
cout<<”name
is”<<” “<<name<<endl;
cout<<”ag
is “<<” “<<age<<endl;
}
};
void
main()
{
emp
e1;
e1.get();
e1.show();
getch();
}
Output:
Enter
name Pramod
Enter
age 21
Name
is Pramod
Age
is 21
No comments:
Post a Comment