iter->second
is a member variable not a function. Remove the parentheses: parent->setName(iter->second);
.
error: no match for call to '(const std::basic_string<char>) ()'
-
04-07-2023 - |
Frage
I have a map which maps a pair of two classes to a simple string. "FirstCollection" and "SecondCollection" are classes, "myCollecttion" is an object of one of them. But when iterating over the map I'm getting a compile error:
error: no match for call to '(const std::basic_string) ()'
typedef std::map <
std::pair < Collection, Envelope::Envelope >
, std::string > NameMap;
NameMap globalNameMap = map_list_of
( std::make_pair ( FirstCollection, Envelope::A ), "Something")
( std::make_pair ( SecondCollection, Envelope::B ), "Another thing")
NameMap::const_iterator iter
= globalNameMap.find( std::make_pair ( myCollection, myEnvelope ));
if ( iter == globalNameMap.end() )
{
parent->setName("anything");
} else {
parent->setName(iter->second());
}
Error in this line: parent->setName(iter->second());
Any suggestions?
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow