class robot_generic
{
public :
template<typename Request, typename Response>
bool const queryDriver(Request const &req, Response &res)
{
//some jobs, blah blah blah
}
template<typename Request, typename Response>
bool const queryMoney(Request const &req, Response &res)
{
//some jobs, blah blah blah
}
};
class robot_A : public robot_generic
{
public :
template<typename Request, typename Response>
bool const queryFood(Request const &req, Response &res)
{
//some jobs, blah blah blah
}
};
class robot_B : public robot_generic
{
public :
template<typename Request, typename Response>
bool const queryFood(Request const &req, Response &res)
{
//some jobs, blah blah blah
}
template<typename Request, typename Response>
bool const queryWater(Request const &req, Response &res)
{
//some jobs, blah blah blah
}
};
class robot_C : public robot_generic
{
public :
template<typename Request, typename Response>
bool const queryWater(Request const &req, Response &res)
{
//some jobs, blah blah blah
}
template<typename Request, typename Response>
bool const queryMovie(Request const &req, Response &res)
{
//some jobs, blah blah blah
}
};
As you can see, every member functions of query are the same
yet I have to reimplement those same member functions in different classes
Although I would like to use policy based design to solve this kind of
composition problem, but it would induce heavy multiple inheritance.
The codes are like this