Showing Page:
1/7
Bahria University, Lahore Campus
Department of Computer Science
Lab Journal 02
(Spring 2021)
Course:
Object Oriented Programming - Lab
Date: _______________
Course Code:
CSL-210
Max Marks: 10
Faculty’s Name:
Ms. Iqra Ashraf
Name: Muhammad Ali Ehtisham Enroll No: 054 Class:BSCS2A
Objective(s):
Upon completion of this lab session, learners will be able to:
Define classes and objects
Lab Tasks:
Task 1
Create an employee class, basing it on previous lab. The
member data should comprise an int for storing the employee
number, a string for storing the name and a float for storing the
employee’s salary. Member functions should allow the user to
enter this data and display it. Write a main () that allows the
user to enter data for three employees and display it.
CODE:
#include<iostream>
#include<string>
using namespace std;
class employee
{
public:
int empno;
string empname;
float salary;
void getdata()
{
cout <<"Enter employee no:";
cin >> empno ;
cout <<endl<< "Enter salary:"<<endl;
cin >> salary;
cout << endl << "Enter employee name:" << endl;
cin >> empname;
}
};
int main()
{
Showing Page:
2/7