2013-10-22 39 views
0

也許你會知道,我得到一個錯誤:錯誤C2440和函子

error C2440: 'initializing' : cannot convert from 'int' 
       Conversion from integral type to pointer type requires reinterpret_cast 

它去'文件中MS VS 2010的文件夾:

template<class _Other1, 
     class _Other2> 
     _Pair_base(_Other1&& _Val1, _Other2&& _Val2) 
     : first(_STD forward<_Other1>(_Val1)), 
      second(_STD forward<_Other2>(_Val2)) 
     { // construct from moved values 
     } 

我一直在尋找不同的解決方案,但可能找不到一個正確的。

+0

'functors'的類型是什麼? – juanchopanza

+0

'對(NULL,sessionStartExit)''不需要'<,>'類型部分。 – billz

+0

@billz:確實需要'<,>'部分。回想一下'pair'是一個模板類(不是類型推導),而不是像'make_pair'這樣的模板函數(它可以從參數中推導出類型)。 –

回答

1

錯誤說你的代碼你分享

'initializing' : cannot convert from 'int' to 'EnterFunctor *' 

只有一部分是

functors.push_back(make_pair(sessionStartFunc, 
    pair<EnterFunctor*, ExitFunctor*>(NULL,sessionStartExit))); 

如果NULL已經#defined爲0這給你一個int但你答應指針的pair,所以錯誤的下一行說你可以使用一個強制轉換來使NULL成爲正確類型的指針。

+0

這是否工作? – doctorlove

+0

是的,謝謝你:-) – pearinthemountains

相關問題