0
Is Implementation correct for class adapter pattern
Please find below code: https://code.sololearn.com/cWuZPn36M1Cw/#cpp Not finding any example for class adapter pattern [struct EmployeeAdapter2]. Is implementation correct? Also feel free to share your view for object adapter pattern [struct EmployeeAdapter] also.
3 Answers
+ 1
struct EmployeeAdapter2 : iEmployee, Human
{
EmployeeAdapter2() = default;
EmployeeAdapter2(string name, string lastName) : Human(name, lastName) {}
void display()
{
Human::display();
}
void getfirstName()
{
Human::display(); // You probably meant getfirstName here
}
void getLastName()
{
Human::display(); // You probably meant getLastName here
}
};
0
Can you Tell me what you want to Code?
0
I want to achieve the same goal i achieved using current code.
Actually, current code EmployeeAdapter
Has composition. This is called object adapter scenario. What if i dont want to use object adapter and use class adapter using inheritance.