Reading about encapsulation in Lippman book, I found the following pargraph
Although user code need not change when a class definition changes, the source files that use a class must be recompiled any time the class changes.
Assuming I have the following code
class A {
private:
int x;
public:
A() { x = 0; }
int x_plus();
}
int A::x_plus(){ return x + 1; }
if I changed the body of x_plus()
to return x+2
, why I shall recompile source file that use it ?
I think it's something related to linking process by C++ , am I right ?