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:
#define protected public
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.
friend class X_accessor;
Then instead of changing the definition of 'protected' change the definition of X_accessor in the file that declares Y.
#define X_accessor Y