[問題] map insert錯誤問題
開發平台(Platform): (Ex: Win10, Linux, ...)
C/C++
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
VC++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
std::map
問題(Question):
在執行insert時,跳出以下errors
餵入的資料(Input):
typedef struct AAA
{
float score;
bool compare;
} AAA;
預期的正確結果(Expected Output):
insert成功
錯誤結果(Wrong Output):
Error C2678 binary '<': no operator found which takes a left-hand operand
of type 'const AAA' (or there is no acceptable
conversion)
C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\include\xstddef 239
程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔)
std::map<AAA, int>AAAInfo;
AAA *pInfo = new AAA[1];
pInfo[0].score = 90;
pInfo[0].compare = true;
int nIndex = 2;
AAAInfo.insert(std::make_pair(pInfo[0], nIndex));
補充說明(Supplement):
用::value_type也一樣
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.163.84.235
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1529588281.A.A24.html
※ 編輯: waquey (118.163.84.235), 06/21/2018 21:39:19
→
06/21 21:48,
7年前
, 1F
06/21 21:48, 1F
→
06/21 21:50,
7年前
, 2F
06/21 21:50, 2F
→
06/21 21:50,
7年前
, 3F
06/21 21:50, 3F
→
06/21 23:09,
7年前
, 4F
06/21 23:09, 4F
※ 編輯: waquey (27.147.28.235), 06/21/2018 23:09:58
→
06/21 23:11,
7年前
, 5F
06/21 23:11, 5F
→
06/22 00:51,
7年前
, 6F
06/22 00:51, 6F
→
06/22 00:52,
7年前
, 7F
06/22 00:52, 7F
推
06/22 04:11,
7年前
, 8F
06/22 04:11, 8F
→
06/22 08:58,
7年前
, 9F
06/22 08:58, 9F
→
06/22 08:59,
7年前
, 10F
06/22 08:59, 10F
→
06/22 12:56,
7年前
, 11F
06/22 12:56, 11F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章