简体   繁体   中英

error: no match for call to '(const std::basic_string<char>) ()'

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?

iter->second is a member variable not a function. Remove the parentheses: parent->setName(iter->second); .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM