Smartdata pvt. ltd company is storing the information of their employees( Name, Department DOB,Gender, address, email and Mob) in different entity according to department of employee. Now, one employee will be shifted from programing team to testing team. Write a code to copy all the details of that employee from one object to another object. Note: Display the above concept with the help of classes and copy constructors.
#include<iostream>
using namespace std;
class employees{
public:
string name,department, dob, gender,address, email,mob;
public:
employees(string name,string department,string dob,string gender,string address,string email,string mob) {
setName(name);
setDepartment(department);
setDob(dob);
setGender(gender);
setAddress(address);
setEmail(email);
setMob(mob);
}
void display(string name,string department,string dob,string gender,string address,string email,string mob) {
cout <<"Name:"<<name<<endl;
cout <<"Department:"<<department<<endl;
cout <<"Dob:"<<dob<<endl;
cout <<"Gender:"<<gender<<endl;
cout <<"Address:"<<address<<endl;
cout <<"Email:"<<email<<endl;
cout <<"Mob:"<<mob<<endl;
}
void setName(string name) {
name = name;
}
string getName() {
return name;
}
void setDepartment(string department) {
department = department;
}
string getDepartment() {
return department;
}
void setDob(string dob) {
dob = dob;
}
string getDob() {
return dob;
}
//gender
void setGender(string gender) {
gender = gender;
}
string getGender() {
return gender;
}
//address
void setAddress(string address) {
address = address;
}
string getAddress() {
return address;
}
//email
void setEmail(string email) {
email = email;
}
string getEmail() {
return email;
}
//mob
void setMob(string mob) {
mob = mob;
}
string getMob() {
return mob;
}
};
int main(){
employees e("test1","CS","3April 1994","Male","test2","test3","888");
e.display("test1","CS","3April 1994","Male","test2","test3","888");
return 0;
}
Comments
Leave a comment