For reasons (mostly around the idea of mock-ability), we have this abstract interface idea...
struct BundleOfInterfaces
{
static Interface1& interface1;
static Interface2& interface2;
...
};
So we access the functions in the interfaces via BundleOfInterfaces::interface1.function1(...)
How can I make the references immutable so nobody can do BundleOfInterfaces::interface1 = MyNewInterface1;
?
Placing const
on it seems to make the reference to a const object, which forces the referenced implementations to have all their methods be const (and prevents internal states).
I know I can hide it behind a getter function and make the actual reference private, but I assume there's some way I can do this with const
, but it doesn't seem to matter where the const
gets placed.