C++ program to get and display employee details

Video Tutorials
Artificial Intelligence Tutorial
Machine Learning Projects TutorialPython Video tutorial
Computer Graphics Video TutorialC++ Video Tutorial
Big Data Analytics Video TutorialSoft Computing Video Tutorial
Placement Video TutorialJava Video Tutorial

C++ program to get and display employee details using an array of objects concept

In this tutorial, we will Learn:

How to write a C++ program to get the employee details (emp no, emp name, basic salary (initialized to 1000 by the constructor) and allowance) of the Employee class through the keyboard using the method GetData() and display them using the method DispData() on the console in the format emp no, emp name, basic salary, allowance.

Video Tutorial:

Program Description:

1. First we create a class named Employee.

2. Data members such as empid, emp name, basic salary and allowances are added as private members of the class.

3. Next, we add a default constructor to initialize the basic salary of all employees to 1000. That is, whenever an object of class employee is created, the basic salary of the employee is initialized to 1000.

4. GetData() and DispData() are the two-member functions. Which are declared in class employee and are defined outside the class using scope resolution operator.

5. In main method an array of employee object is created to store multiple employee information.

6. Finally, GetData() is called three times to store the 3 employee information and DispDat() is called 3 times to display the employee information.

The following program demonstrates the C++ program to get and display employee details using an array of objects concept

 using namespace std;
 class Employee
         int empid;
         char empname[20];
         int bsalary;
         int allowance;
             bsalary = 1000;
         void GetData();
         void DispData();
 void Employee::GetData()
     cout<<"Enter the employee id: ";
     cout<<"Enter the employee name: ";
     cout<<"Enter the employee allowace: ";
 void Employee::DispData()
 int main()
     Employee e[3];
     cout<<"Enter the employee information:"<<endl;
     for(int i=0;i<3;i++)
     cout<<endl<<"The employee information is:";
     cout<<endl<<"EmpID \t Name \t Bsalary \t Allowance";
     for(int i=0; i<3;i++)


Enter the employee information:

Enter the employee id: 123

Enter the employee name: Mahesh

Enter the employee allowace: 100

Enter the employee id: 234

Enter the employee name: Vidya

Enter the employee allowace: 300

Enter the employee id: 345

Enter the employee name: Prabhas

Enter the employee allowace: 500

The employee information is:

EmpID Name Bsalary Allowance

123 Mahesh 1000 100

234 Vidya 1000 300

345 Prabhas 1000 500


In this article, we understood how to write C++ program to get and print employee details using an array of objects concept.

If you like the tutorial share it with your friends. Like the Facebook page for regular updates and YouTube channel for video tutorials.

1 thought on “C++ program to get and display employee details”

Leave a Comment

Your email address will not be published. Required fields are marked *