"error: base operand of ‘->’ has non-pointer type ‘***’" error when calling a method from another class with iterator
<p>I'm implementing a method which searches an object of type <code>Object</code> by its name within an associative array. Then displays its elements by using a method <code>display</code> which is defined within the class <code>Object</code>. The method is implemented this way:</p>

<pre><code>//Method SearchObject in class Gestion
#include "object.h"
void Gestion::SearchObject(string nameobj) const{

    stringstream ss;

    auto it = objectname.find(nameobj);
    if (it == objectname.end())
        cout &lt;&lt; "Not found!" &lt;&lt; endl;
    else
           (*it)-&gt;display(ss); //Error reported in this line
           cout &lt;&lt; ss.str() &lt;&lt; endl;
}
</code></pre>

<p>Nevertheless, when compiling I get the following error:</p>

<pre><code>error: base operand of ‘-&gt;’ has non-pointer type ‘const std::pair&lt;const std::basic_string&lt;char&gt;, std::shared_ptr&lt;Object&gt; &gt;’
            (*it)-&gt;display(ss);
</code></pre>

<p>The method <code>display</code> is declared within the class <code>Object</code> and I have already tested by calling it from other classes. In the header of class <code>Gestion</code> the variables are declared this way:</p>

<pre><code>//File gestion.h
typedef std::shared_ptr&lt;Object&gt; ObjPtr;
typedef map&lt;string, ObjPtr&gt; Objectmap;

class Gestion { 
private:
         Objectmap objectname;
public:
    Gestion(Objectmap objectname);
    virtual ~Gestion() {}

    virtual void SearchObject(string nameobj) const; 
};
</code></pre>

<p>How can I use the method <code>display</code> within this new method I'm implementing?</p>