const-correctness when passing complex types
<p>So, I have four classes:</p>

<p><em>App</em> - this represents the entry-point for the application</p>

<p><em>MainPage</em> - this represents the home screen</p>

<p><em>Authenticator</em> - this represents a helper/utility class for authentication</p>

<p><em>LoginPage</em> - this represents a login screen.</p>

<p>App, MainPage, and LoginPage all have pointers to an Authenticator, and it is, in-fact, passed from App, to MainPage, to LoginPage as the user starts the app, reaches the main screen, and is prompted to log in. App creates MainPage, and if MainPage needs to log in, it creates LoginPage. The Authenticator pointer is passed at creation.</p>

<p>Let's say Authenticator looks something like this:</p>

<pre><code>class Authenticator {
public:
   std::string GetToken() const;
   void Login(std::string username, std::string pass);
}
</code></pre>

<p>Now, App will create a normal, non-const pointer to Authenticator but because I don't want MainPage to be able to modify Authenticator, I want it to store a const pointer to it (ie so it can only call const member functions on it). However, I would like LoginPage to be able to call non-const member functions, like Login(), so when I pass my Authenticator from MainPage to LoginPage, I'll need to cast away the const-ness. </p>

<p><strong>My question is</strong>: is it bad to do so in this situation? Should a class that is not allowed to modify an object be able to pass it to one that can? Or would it be better to have App create MainPage and LoginPage at the same time, and give them both the same Authenticator to start with? My only problem with that option is that I create a LoginPage actively, rather than lazily, and I'd prefer to do it lazily.</p>

<p>Thanks in advance.</p>
