我有以下代碼C++函數(收費和常量)
//*********************************************
Section&
BasicConfig::section (std::string const& name)
{
return map_[name];
}
//*************************************************
Section const&
BasicConfig::section (std::string const& name) const
{
static Section none("");
auto const iter = map_.find (name);
if (iter == map_.end())
return none;
return iter->second;
}
如果我寫:section("database_path");
哪個腳本會被執行?
你在'const'上調用它的對象是不是? – NathanOliver
爲什麼不嘗試呢? – Igor
@Igor:他不會從簡單的嘗試中學到很多東西。 –