FmD4FRX3FmXvDZXvGZT3FRFgNBP1w326w3z1NBMhNV5=
items

cs302 assignment 3 solution 2022

 

cs302 assignment 2 solution 2021

Solution:👇

#include<iostream>

using namespace std;

class Employee

{

private:

string emp_Id;

string emp_Name;

int joiningYear;

int joiningMonth;

int joiningDate;

public:

Employee()

{

emp_Id = "<<EMPTY>>";

emp_Name = "<<EMPTY>>";

joiningYear=0;

joiningMonth=0;

joiningDate=0;

}

Employee(string id, string name, int year, int month, int date)

{

emp_Id = id;

emp_Name = name;

joiningYear=year;

joiningMonth=month;

joiningDate=date;

}

void setValues(Employee *emp2)

{

emp_Id = emp2->emp_Id;

emp_Name = emp2->emp_Name;

joiningYear=emp2->joiningYear;

joiningMonth=emp2->joiningMonth;

joiningDate=emp2->joiningDate;

}

string getId()

{

return emp_Id;

}

string getName()

{

return emp_Name;

}

int getYear()

{

return joiningYear;

}

int getMonth()

{

return joiningMonth;

}

int getDate()

{

return joiningDate;

}

void display(Employee emp)

{

cout<<"ID: "<<emp.getId()<<"\n";

cout<<"Name: "<<emp.getName()<<"\n";

cout<<"Joining Year: "<<emp.getYear()<<"\n";

cout<<"Joining Month: "<<emp.getMonth()<<"\n";

cout<<"Joining Date: "<<emp.getDate()<<"\n";

}

};

int main()

{

Employee emp1;

Employee emp2("BC210200401", "Jannat Bibi", 2021,03,17);

cout<<"Employee 1 Using default Constructor:"<<"\n";

emp1.display(emp1);

cout<<"Employee 2 Using Parameterized constructor:"<<"\n";

emp2.display(emp2);

cout<<"Employee 1 having Employee 2 copied data member values"<<"\n";

emp1.setValues(&emp2);

emp1.display(emp1);

return 0;

}

Click below to download in txt👇

Click below to join the WhatsApp group

Cs302 whatsapp group link👈




0/Post a Comment/Comments

Partner

73745675015091643