In Java or C# (and of course in C++), you could have a token system where the token can only be provided by Device :
VFS: void register(DeviceToken):
DeviceToken: empty interface (marker)
Device: private DeviceToken provideDeviceToken();
This hides both VFS and Device classes from accessing each others' private members.
You can also constrain how gets to provide DeviceToken by adding sufficient comments in code.
In Java or C# (and of course in C++), you could have a token system where the token can only be provided by Device :
VFS: void register(DeviceToken):
DeviceToken: empty interface (marker)
Device: private DeviceToken provideDeviceToken();
This hides both VFS and Device classes from accessing each others' private members.
You can also constrain how gets to provide DeviceToken by adding sufficient comments in code.