Reputation: 33
I can't make map
work with a class, what's wrong here? I can't figure it out, please help:
#include <map>
#include <iterator>
class base {
public:
bool delete_lowest(map<char, double> &frequencies)
{
double min=1; char del ; box b1;
for (iterator itr = frequencies.begin(); itr != frequencies.end(); ++itr)
{
if(itr->second < min)
{
min= itr->second ;
del= itr->first ;
}
}
frequencies.erase(del) ;
return true;
}
I am getting errors like "map is not declared" and so on. I think the way I code is not the proper way. so how do I proceed? Thanks
Upvotes: 0
Views: 147
Reputation: 1067
There are three solutions to your error:
map
use std::map
using std::map
before your classusing namespace std
before your class.Upvotes: 2
Reputation: 5814
map
is in the std
namespace. Try
bool delete_lowest(std::map<char, double> &frequencies)
Upvotes: 5