labs 1-6: init

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-24 14:03:08 +05:30
commit ad185c994e
26 changed files with 2250 additions and 0 deletions

88
lab5/14.cpp Normal file
View File

@@ -0,0 +1,88 @@
#include <iostream>
using namespace std;
class BasicInfo {
private:
char name[30];
int empId;
char gender;
public:
void getData();
void putData();
};
void BasicInfo::getData() {
cout << "Name: ";
cin >> name;
cout << "Employee ID: ";
cin >> empId;
cout << "Gender: ";
cin >> gender;
}
void BasicInfo::putData() {
cout << "Name: " << name << endl
<< "Employee ID: " << empId << endl
<< "Gender: " << gender << endl;
}
class DeptInfo : public BasicInfo {
private:
char deptName[30];
char assignWork[30];
int timeToComplete;
public:
void getData();
void putData();
};
void DeptInfo::getData() {
BasicInfo::getData();
cout << "Name of Department: ";
cin >> deptName;
cout << "Assigned Work: ";
cin >> assignWork;
cout << "Time to complete: ";
cin >> timeToComplete;
}
void DeptInfo::putData() {
BasicInfo::putData();
cout << "Name of Department: " << deptName << endl
<< "Assigned Work: " << assignWork << endl
<< "Time to complete: " << timeToComplete << endl;
}
class EmployeeInfo : public DeptInfo {
private:
int salary;
int age;
public:
void getData();
void putData();
};
void EmployeeInfo::getData() {
DeptInfo::getData();
cout << "Salary of employee: ";
cin >> salary;
cout << "Age of employee: ";
cin >> age;
}
void EmployeeInfo::putData() {
DeptInfo::putData();
cout << "Salary of employee: " << salary << endl
<< "Age of employee: " << age << endl;
}
int main() {
EmployeeInfo e;
e.getData();
e.putData();
return 0;
}