2014-05-19 74 views
-2

類MessageBase具有像這樣的公共模板成員函數:正確語法來訪問一個模板函數

/*! Get a pointer to a field. Inplace, 0 copy. 
     \tparam T type of field to get 
     \return pointer to field or 0 if not present */ 
    template<typename T> 
    const T *get() const 
    { 
      Fields::const_iterator fitr(_fields.find(T::get_field_id())); 
      return fitr == _fields.end() ? 0 : &fitr->second->from<T>(); 
    } 

當我聲明指針的類型T(在這種情況下TEX :: MDEntryPx)

const TEX::MDEntryPx *price = me->get(); 

然後嘗試訪問的功能,鐺++與

main.cpp|338|error: no matching member function for call to 'get' 

回來我沒有使用正確的語法但不知道它是什麼?

+1

什麼是'me'的聲明? –

回答

0

咄,

const TEX::MDEntryPx *price = me->get<TEX::MDEntryPx>();