I want to avoid recompilation of everything that includes a public header file, just because something changed in the private part of a class definition. I'm investigating other options beside PIMPL.
This is what I tried:
I created a library that contains a class A:
A_p.h contains private part of class A
void PrivateMethod(int i);
A.h the public header file:
class A
{
public:
A();
virtual ~A();
// other public members
private:
#ifdef A_PRIVATE
#include "A_p.h"
#endif
};
A.cpp
#define A_PRIVATE
#include "A.h"
A::A() {}
A::~A() {}
void A::PrivateMethod(int i) { }
I then created an Win32 console project that includes the public header (A.h) and links against the .lib file.
Everything seems to work, but I'm wondering for any pitfalls along the way. Can anyone elaborate on this?