Object-Oriented Programming Lab Task, Lab Reports of Object Oriented Programming

A lab task on Object-Oriented Programming. It provides instructions on how to create a class with data members and member functions, inherit from multiple classes, and write a test program to demonstrate the classes' capabilities. sample code written in C++.

Typology: Lab Reports

2022/2023

Available from 12/14/2022

razaroghani
razaroghani 🇵🇰

4.5

(4)

151 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
OOPs Lab Lab # 06 1
Lab Task 6.1: Create a class personalDetails which has three data members name, gender and address.
This class has a member function getPersonalDetails to get these details from user. Create a new class
deptDetails which has also three data members deptName, Id and assignedTask. This class has a
member function getDeptDetails to get these details from the user. Now inherit a new class employee
from both these classes. This class has a member function print to display all these details. Write a test
program that demonstrates all these classes’ capabilities.
#include<iostream>
#include<stdlib.h>
using namespace std;
class personalDetails
{
protected:
string Name,Gender,Address;
public:
void get_personalDetails()
{
cout<<"Enter Your personalDetails Informations:"<<endl;
cout<<"Enter Your Name: ";
getline(cin,Name);
cout<<"Enter Your Gender: ";
getline(cin,Gender);
cout<<"Enter Your Address: ";
getline(cin,Address);
}
};
class Dept_Details
{
protected:
string Dept_Name,ID,Assigned_Task;
public:
void get_dept_details()
{
cout<<"Enter Your Departmental Informations:"<<endl;
cout<<"Enter Your Department Name: ";
getline(cin,Dept_Name);
cout<<"Enter Your ID: ";
getline(cin,ID);
cout<<"Enter the Details of Your Assigned Task: ";
getline(cin,Assigned_Task);
}
};
class Employee:public personalDetails,public Dept_Details
{
public:
void print()
{
cout<<"Your Informations Are Given Below"<<endl;
cout<<"Name: "<<Name<<":"<<endl;
pf3
pf4

Partial preview of the text

Download Object-Oriented Programming Lab Task and more Lab Reports Object Oriented Programming in PDF only on Docsity!

Lab Task 6.1: Create a class personalDetails which has three data members name, gender and address. This class has a member function getPersonalDetails to get these details from user. Create a new class deptDetails which has also three data members deptName, Id and assignedTask. This class has a member function getDeptDetails to get these details from the user. Now inherit a new class employee from both these classes. This class has a member function print to display all these details. Write a test program that demonstrates all these classes’ capabilities. #include #include<stdlib.h> using namespace std; class personalDetails { protected: string Name,Gender,Address; public: void get_personalDetails() { cout<<"Enter Your personalDetails Informations:"<<endl; cout<<"Enter Your Name: "; getline(cin,Name); cout<<"Enter Your Gender: "; getline(cin,Gender); cout<<"Enter Your Address: "; getline(cin,Address); } }; class Dept_Details { protected: string Dept_Name,ID,Assigned_Task; public: void get_dept_details() { cout<<"Enter Your Departmental Informations:"<<endl; cout<<"Enter Your Department Name: "; getline(cin,Dept_Name); cout<<"Enter Your ID: "; getline(cin,ID); cout<<"Enter the Details of Your Assigned Task: "; getline(cin,Assigned_Task); } }; class Employee:public personalDetails,public Dept_Details { public: void print() { cout<<"Your Informations Are Given Below"<<endl; cout<<"Name: "<<Name<<":"<<endl;

cout<<"Gender: "<<Gender<<":"<<endl; cout<<"Addresst: "<<Address<<":"<<endl; cout<<"Department Name: "<<Dept_Name<<":"<<endl; cout<<"ID: "<<ID<<":"<<endl; cout<<"Assigned Task: "<<Assigned_Task<<":"<<endl; } }; int main() { system("color F0"); Employee E; E.get_personalDetails(); E.get_dept_details(); E.print(); return 0; }

system("color F0"); Square sqr; Cube cub; sqr.get_number(); sqr.square_of_number(); cout<<endl; cub.cube_of_number(); return 0; }