Nothing Special   »   [go: up one dir, main page]

Lab 6

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Task 1

#include<iostream>

using namespace std;

class Employee

int EmployeeId;

long Scale;

public:

Employee()

cout << "Employee class default constructor\n";

Employee(int x, long y)

this->EmployeeId = x;

this->Scale = y;
}

void GetData()

cout<<"\nEnter Employee Id : ";

cin>>EmployeeId;

cout<<"\nEnter Employee Scale : ";

cin>>Scale;

void PutData()

cout<<"\n\nEmployee Id : "<<this->EmployeeId;

cout<<"\nEmployee Salary : "<<this->Scale;

};

class Manager: public Employee

int managerId;
string department;

public:

Manager(int i, long j) : Employee(i,j){}

void GetData()

cout<<"\nEnter Manager Id : ";

cin>>managerId;

cout<<"\nEnter Manager's department : ";

cin>>department;

void PutData()

cout<<"\nManager Id : "<<managerId;

cout<<"\nManager Department : "<<department;

};

int main()
{

Manager m(1,25000);

m.GetData();

m.Employee::PutData();

m.PutData();

return 0;

Task 2\
#include<iostream>

using namespace std ;

class student{

protected:

int admission_no;

string name;

int age;

string addresss;

string depattment;

public:

set_students()

cout<< "admission_no"<< endl;

cin >> admission_no;

cout<< " name"<< endl;

cin >> name;

cout << "age "<<endl;

cin >> age;

cout << "addresss"<< endl ;

cin >> addresss;

get_data(){

cout<< "admission_no :" <<admission_no<< endl;


cout<< " name :"<<name<< endl;

cout << "age :"<<age<<endl;

cout << "addresss :"<<addresss<< endl ;

};

class drived1: public student{

protected:

string depatment;

public:

void setdata(){

cout << " depatment"<< endl;

cin >> depatment ;}

get_data()

cout<<"**undergrad***"<<endl;

cout << " depatment :"<<depatment<< endl;

};
class drived: public student {

protected:

string depatment;

public :

void setdata(){

cout << " depatment"<< endl;

cin >>depatment ;}

get_data()

cout<<"***graduate***"<<endl;

cout << " depatment : "<<depatment<< endl;

};

int main (){

student s,s1;

drived1 g;

drived u;
char press;

cout<<"press "<<endl;

cin>>press;

if(press=='x'){

g.setdata();

g.get_data();

s.set_students();

s. get_data();

else if (press== 'y'){

u.setdata();

u.get_data();

s1.set_students();

s1. get_data();

}
Task 3

#include <iostream>

using namespace std;

// Base class Mammal

class Mammals {

public:

void Function_1() {

cout << "I am mammal.\n" ; //

};

// Another base class MarineAnimals


class MarineAnimals {

public:

void Function_2() {

cout << "I am a marine animal.\n" ;

};

// Derived class BlueWhale inheriting both base classes

class BlueWhale: public Mammals, public MarineAnimals {

public:

void Function_3() {

cout << "I belong to both the categories: Mammals as well as Marine Animals.\n" ;}

};

int main() {

// Creating objects of each class

Mammals m1;

MarineAnimals ma1;

BlueWhale bw1;

// Calling the functions

m1.Function_1();

ma1.Function_2();

bw1.Function_3();
// Calling parent class functions

bw1.Function_1();

bw1.Function_2();

return 0;

You might also like