class StationSongs {
protected:
int original_song;
};
class NewsRadio: public StationSongs {
public:
NewsRadio()
{
current_song = NULL;
currently_empty = 0;
original_song = 0;
start_time_of_song = 0;
next_song_to_play = NULL;
}
};
class CommercialRadio : public StationSongs {
public:
CommercialRadio() {
current_song = NULL;
currently_empty = 0;
original_song = 0;
start_time_of_song = 0;
next_song_to_play = NULL;
}
};
问题:我想使用继承的类作为map Value
地图是:
typedef MtmMap<double, StationSongs*> RadioMap;
method{
CommercialRadio new_station();
RadioPair new_pair(stationFrequency,*new_station);
radio.insert(new_pair);
}
我收到此错误:
Multiple markers at this line
- no matching function for call to 'mtm::MtmMap<double, mtm::StationSongs*>::Pair::Pair(double&,
mtm::CommercialRadio
(&)())'
我怎样才能解决这个问题?
答案 0 :(得分:1)
CommercialRadio new_station();
声明一个函数new_station
,它不带参数并返回CommercialRadio
。删除括号。 C ++语言的这个属性称为most vexing parse。
此外,基类没有定义虚拟析构函数几乎肯定是错误的。