You can add
in the body of the X class declaration near the top.
You can also un-protect everything in a class header you #include like this:
Code:
#define protected public
#include "X.h"
#undef protected
but that header must be the first header #included or you'll unprotect everything that loads while this new definition is effective.
The above is only for classes you can't easily rewrite or for quick testing your concepts.
Another approach would be to make a friend class that doesn't exist so that it can be #defined when the header loads.
Something like this.
Code:
class X
{
friend class X_accessor;
...
};
Then instead of changing the definition of 'protected' change the definition of X_accessor in the file that declares Y.
Code:
#define X_accessor Y
#include "X.h"
#undef X_accessor