2017-02-04 30 views
1

構建使用tinyXml2的項目後,出現以下三個錯誤。附件中顯示錯誤。有問題的代碼可以在tinyXml2的xtree.cs文件中找到,在這裏:tinyXml2在編譯時導致錯誤C2675 - xtree.cs

template<class _Iter> 
    void insert(_Iter _First, _Iter _Last) 
    { // insert [_First, _Last) one at a time 
    _DEBUG_RANGE(_First, _Last); 
    for (; _First != _Last; ++_First) 
     { // insert element as lvalue 
     const value_type& _Val = *_First; 
     insert(end(), _Val); 
     } 
    } 

tinyXml2_Errors

我使用(而且必須繼續使用)VS2010

什麼會導致這些錯誤?

1)錯誤C2675:一元 '++': '的std :: string' 不限定此運算符或轉換到類型接受的預先規定的操作

2)錯誤C2100:非法間接

3)錯誤C2440:初始化:不能從 '的std :: string' 轉換爲 '常量標準::對< _Ty1,_Ty2> &'

編輯:包括錯誤

回答

0

我的一切評論類(和頭),並添加代碼,直到我收到錯誤。這個失敗實際上不是由於tinyXml2導致的 - 這是將字符串插入地圖的失敗。

對於將來會出現此問題的其他人,這裏是違規函數,它在Visual Studio中不會產生任何扭曲的紅線。解決這個問題

map<string, string> createMap(CNintendoItem ni) 
    { 
    map<string, string> xmlNodeToValue; 

    //ItemName is a string constant. ni.Name is a string returned from a class 
    xmlNodeToValue.insert(ItemName, ni.Name);//name of the item 

    ...//several more insertions 

    return xmlNodeToValue; 
} 

一種方法是使用下面的方法將值分配給一個新的關鍵:

xmlNodeToValue[ItemName] = ni.Name;//name of the item 
相關問題