The Pimpl is a little confusing for me.Code:class Hat { struct Cat; Cat * cat; public: Hat() { cat = new Cat; } ~Hat() { delete cat; } void printCat() { cout << cat->name << endl; } }; // version 1 class Cat { public: string name; Cat() { name = "Lucy"; } }; // version 2 class Cat { public: string color; string name; Cat() { color = "Brown"; name = "Lucy"; } }; int main() { Hat hat; hat.printCat(); return 0; }
Here in my example Hat has a Cat* so that it will all work fine even when Cat gets changed. So called, binary compatibility.
Now if I compiled my program using version 1 but now I have access to version 2 .dll then. Will it not fail? Why it will not fail?