The Code given below can be used in TURBO C++ Compilers: -
#include<iostream.h>
#include<conio.h>
class Employee
{
int eid;
char ename[100];
float basic_salary;
public:
void accept_details()
{
cout<<"\n Enter Employee Id : ";
cin>>eid;
cout<<"\n Enter Employee Name : ";
cin>>ename;
cout<<"\n Enter Basic Salary : ";
cin>>basic_salary;
}
void display_details()
{
cout<<"\n -------------------------- ";
cout<<"\n Employee Id : "<<eid;
cout<<"\n Employee Name : "<<ename;
cout<<"\n Basic Salary : "<<basic_salary;
}
};
void main()
{
clrscr();
Employee e;
e.accept_details();
e.display_details();
getch();
}
//...........Coded by Rishab Nair
The Code given below can be used in gcc/g++ Compilers: -
#include <iostream>
using namespace std;
class Employee
{
int eid;
char ename[100];
float basic_salary;
public:
void accept_details()
{
cout<<"\n Enter Employee Id : ";
cin>>eid;
cout<<"\n Enter Employee Name : ";
cin>>ename;
cout<<"\n Enter Basic Salary : ";
cin>>basic_salary;
}
void display_details()
{
cout<<"\n -------------------------- ";
cout<<"\n Employee Id : " <<eid;
cout<<"\n Employee Name : " <<ename;
cout<<"\n Basic Salary : " <<basic_salary;
}
};
int main()
{
Employee e;
e.accept_details();
e.display_details();
return 0;
}
//...........Coded by Rishab Nair
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP