我是C++菜鸟,所以如果你觉得这个问题很傻,请不要介意
我在C++中声明地图如下:
std::map<CartesianLocation, std::list<RadioSignal<RadioDevice>>> radioMap;
Run Code Online (Sandbox Code Playgroud)
完整代码:
不知道但是使用下面的代码,我能够解决我的问题类RadioMap:public std :: iterator_traits,public Cloneable {private:
std::map<const CartesianLocation*, const std::list<RadioSignal<RadioDevice>>*> radioMap;
std::vector<RadioDevice> radioDevices;
Run Code Online (Sandbox Code Playgroud)
public:void add(const CartesianLocation*location,const std :: list>*observedSignals){radioMap [location] = observedSignals; }
在这一行,radioMap[location] = observedSignals;我结束了这个错误
"无效的二进制表达式操作数('const CartesianLocation'和'const CartesianLocation')"在struct _LIBCPP_TYPE_VIS_ONLY上更少:binary_function <_Tp,_Tp,bool> {_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp&__ x,const _Tp&__y)const {return __x <__y;}};
知道我哪里错了吗?
struct comp
{
bool operator()(const CartesianLocation& loc1, const CartesianLocation& loc2)
{
//Compare the 2 locations, return true if loc1 is less than loc2
return loc1.id < loc2.id;
}
};
std::map<CartesianLocation, std::list<RadioSignal<RadioDevice>>, comp> radioMap;
public:
void add(CartesianLocation location, std::list<RadioSignal<RadioDevice>> observedSignals) {
radioMap[location] = observedSignals;
}
Run Code Online (Sandbox Code Playgroud)
在这一行,radioMap[location] = observedSignals;我得到以下错误:
如果(__tree_.value_comp()。key_comp()(__ k,__nd-> __ value _.__ cc.first))在此行上没有调用'const RadioMap :: comp'类型的对象的匹配函数
知道我哪里错了吗?
c++ ×2