I always see people asking how you convert from a structure to a class but never the other way around. Is it because it's much simpler or is it for another reason? Let's say you have a department class like the one below:
class Department {
private:
int DepartmentID;
string Departmentname;
string DepartmentHeadName;
public:
Departments() {
DepartmentID = 0;
Departmentname = "";
DepartmentHeadName = "";
}
Departments(int di, string dn, string dhn)
{
DepartmentID = di;
Departmentname = dn;
DepartmentHeadName = dhn;
}
void setdepartmentid(int di) {
DepartmentID = di;
}
int getdepartmentid() {
return DepartmentID;
}
void setDepartmentName(string dn) {
Departmentname = dn;
}
string getDepartmentName() {
return Departmentname;
}
void setDepartmentHeadname(string dhn) {
DepartmentHeadName = dhn;
}
string getDepartmentHeadname() {
return DepartmentHeadName;
}
};
And you were asked to "Replace class with structure for Department." How would you approach this? Would you simply remove class and replace it with struct or would you do/try something else?