2014-03-26 18 views
-5

我想通過爲重複函數寫一個通用代碼來優化源代碼。我正在嘗試使用模板函數來實現相同的功能。通用函數

但是我無法解決以下錯誤。 同樣的任何幫助都是值得讚賞的。

namespace elements_z0 
{ 

Celements_z0::init() {...} 
Celements_z0::run() {...runUser();...} 
Celements_z0::runUser() 
{.... 
//generic func 
alice::CAliceOutput* alice_p; 
runUser_r(alice_p, m_aliceSenderpin, m_alicecallback_p, m_aliceSenderpin_aui8, t_alice_enum); 
....} 

template<typename Interface> void runUser_r(Interface* interface_p, uint8_t* pin, interfacetype_p<Interface> interfacetyp_p, uint32_t Ifid_u32) 
{ 
.......} 

錯誤

  1. 錯誤:#504-d:非標準形式用於拍攝成員函數的地址
  2. 錯誤:#849:表達式必須具有算術,enum或指針類型

    runUser_r(alice_p,m_aliceSenderpin,m_alicecallback_p,m_aliceSenderpin_aui8,t_alice_enum);

編輯1:

很抱歉的錯字錯誤

+2

哪些問題?請更具體一些。 – usr1234567

回答

4

嘗試

template<typename Interface> 

而不是

template(typename Interface)