I have Manager class that inherit multiple interfaces and implements them.
class iperson
{
public:
virtual void doSomething1() = 0;
}
class imachine
{
public:
virtual void doSomething2() = 0;
}
class ibook
{
public:
virtual void doSomething3() = 0;
}
class Manager: iperson, imachine, ibook
{
public:
void doSomething1() override
{/** implemetation **/}
void doSomething2() override
{/** implemetation **/}
void doSomething3() override
{/** implemetation **/}
/***
another code and implemetation
****/
}
And there is Employee class that takes Manager implementation as input for his constructor
class Employee
{
Employee(iperson& person, imachine& machine, ibook& book)
{ /*** some code ***/ }
}
And when i need to pass Manger to Employee from Manager class, I end up with code like this
/** That looks bad passing three this XD **/
Employee employee(*this, *this, *this);
Why using interfaces instead of passing Manager reference?(what i'm trying to achieve) 1- to be able to mock these methods while testing the employee class 2- to restrict access of employee classes to just these methods, not all Manager methods
So the question is: is there better solution and is there a way to istead passing the three (*this) just passing one or something?
Aucun commentaire:
Enregistrer un commentaire