STL map 的关键字key 的类型有限制吗?可以是类类型吗?
1条回答 默认 最新
- oyljerry 2015-08-18 03:28关注
可以是类类型,但是你的类要实现operator <
bool operator<(const a& a1, const a& a2) { if ( a1.m_a>=a2.m_a ) return false; return true; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
可以是类类型,但是你的类要实现operator <
bool operator<(const a& a1, const a& a2)
{
if ( a1.m_a>=a2.m_a )
return false;
return true;
}