【发布时间】:2015-11-02 02:46:49
【问题描述】:
我需要帮助来弄清楚如何调用在地图中保存的类的成员函数。
基本上我有一个包含一个对象的映射,我试图调用它的一个成员函数,因为我不断收到我无法处理的编译器错误。 这是我目前拥有的函数调用的代码示例。
map<int, DailyReport> statContainer;
for (auto x : statContainer)
{
if (x.first < yearAfter && x.first > year)
{
daycounter += 1;
fullYearHtemp += x.second.getHighTemp;
fullYearLtemp += x.second.getLowTemp;
fullYearPercip += x.second.getPercip;
}
}
这甚至可能吗?我是不是搞错了?
编辑:getHighTemp、getLowTemp 和 getPercip 都是 DailyReport 类的成员函数。我需要在 DailyReport 对象位于地图内时访问这些函数。
【问题讨论】:
-
getHeightTemp、getLowPercent等是成员还是成员函数? -
抱歉没有说明,它们是成员函数。
标签: c++ class dictionary member-functions