私はこのような構造を宣言した - >C++で構造体をマップできないのはなぜですか?
struct data{
int x,y;
bool operator < (const data& other) {
return x<other.x or y<other.y;
}
};
今、私はキーとしておよびbool
値でそれをmap
たい。
int main()
{
data a;
map<data,bool>mp;
a.x=12, a.y=24;
mp[a]=true;
}
最後の行は私にこのエラーが発生します - >
error: passing 'const' as 'this' argument of 'bool data::operator<(const data&)' discards qualifiers
が、私はこれをどのように問題を解決できますか?
'or'は何ですか? – Ajay
これは '||'と同じです – jbsu32
また、 'and'は' && 'と同じです。 – jbsu32