Is it possible to return a reference of an object inside a multimap? This is what I’m trying:
return &this->noteList.find(key)->second;
But I’m getting Non-const lvalue reference to type 'Note' cannot bind to a temporary of type 'Note *'so I was wondering if it’s even possible, and if so, how? notelist is the multimap and it has Noteobjects inside it.
this->noteList.find(key)->secondalready gives you a reference to an object inside a multimap (ifthis->noteListis a multimap).By prefixing that expression with an ampersand (
&), you get a pointer to such an object (if that operator is not overloaded)