invalid const_cast from type ‘std::vector<Message>**’ to type ‘std::vector<Message*>*’
<p>I get an error in a function return statement. I have difficulties with understanding what will I return if the function declaration is :</p>

<pre><code>const vector&lt;Message*&gt;&amp; getMessages(string messageBox) const;
</code></pre>

<p>I have class Message, Box and MessageBox:</p>

<pre><code>class Box
{
public:
    vector &lt;Message&gt; *messages;
    string name;
public:
    Box();
       ~Box();
};

class MessageBox
{
public:
    MessageBox(); 
    ~MessageBox(); 
        const vector&lt;Message&gt;&amp; getMessages(string messageBox) const;
private:
    Box *inbox;
};
</code></pre>

<p>Now I'm trying to implement function getMessages. I try to return vector  *messages of 
Box *inbox. It looks like:</p>

<pre><code> const vector&lt;Message&gt;&amp; MessageBox::getMessages(string messageBox) const
{
   if(messageBox == "inbox")
     return (const_cast  &lt;vector&lt;Message&gt;&amp;&gt;(inbox-&gt;messages));
}
</code></pre>

<p>This gives me an error mentioned earlier. Maybe, I should change my variables.<br>
Any ideas? Thank you.</p>
