Reputation: 113
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;
}
};
The problem : I want to use inherited classes as map Value
The map is:
typedef MtmMap<double, StationSongs*> RadioMap;
method{
CommercialRadio new_station();
RadioPair new_pair(stationFrequency,*new_station);
radio.insert(new_pair);
}
I get This error :
Multiple markers at this line
- no matching function for call to 'mtm::MtmMap<double, mtm::StationSongs*>::Pair::Pair(double&,
mtm::CommercialRadio
(&)())'
How can i Solve this ???
Upvotes: 0
Views: 82
Reputation: 545568
CommercialRadio new_station();
declares a function new_station
that takes no arguments and returns a CommercialRadio
. Remove the parentheses. This property of the C++ language is known as the most vexing parse.
Furthermore, it’s almost certainly incorrect that your base class doesn’t define a virtual destructor.
Upvotes: 1