According to this article, it's trying to explain the problem which pimpl
solve but i see that there is no problem in example he showed.
It says that: "there is an issue with below design (that could be serious or not, depending on how many clients Fridge has). Since Fridge.h #includes Engine.h, any client of the Fridge class will indirectly #include the Engine class. So when the Engine class is modified, all the clients of Fridge have to recompile, even if they don’t use Engine directly."
#include "Engine.h"
class Fridge
{
public:
void coolDown();
private:
Engine engine_;
};
#include "Fridge.h"
void Fridge::coolDown()
{
/* ... */
}
But, i see that if Engine
is modified, Fridge
should modify according. And since Fridge
will modify, the Client
which uses Fridge
will also get modified.
In other words, If Engine
get modified, then Fridge
should be recompiled and according to that, Client
also will be recompiled. In this case Client
modified because Fridge
is modified NOT because Engine
is modified.
So, there is no indirection problem in this situation.
Am i right? if yes, So, what's the actual problem does pimpl
solve? if no, can you give me an indirection example which explain this problem?