Error C2064: the term does not evaluate a function that takes 0 arguments

everything! I maintain a channel data group in a map container from which you can access the data of individual channels by channel name. In this regard, I am writing a simple GetIRChannelData function (see the following code). When executing the command pusIRChannelData = cit->second(); an error is issued that reads

 error C2064: term does not evaluate to a function taking 0 arguments 

The whole function performed is nothing more than a search for a specific channel name / identifier in the map container and assigning it to a pointer to a temporary pointer, if found. Could you show me what happened?

 const Array2D<unsigned short>* GetIRChannelData(std::string sChannelName) const { const Array2D<unsigned short>* pusIRChannelData = NULL; for (std::map<std::string, Array2D<unsigned short>* >::const_iterator cit = m_usIRDataPool.begin(); cit != m_usIRDataPool.end(); ++cit) { std::string sKey = cit->first; if (sKey == sChannelName) { pusIRChannelData = cit->second(); // Error occurred on this line break; } } return pusIRChannelData; } 
+7
source share
2 answers

The error message is pretty clear ... you are calling a function that does not exist. map::iterator points to a std::pair , which has two member objects, first and second . Please note that these are not functions. Remove () from the corresponding line and the error should go away.

+12
source

It seems that cit->second does not identify a function pointer. The definition of your iterator is asserted by its pointer to (Array2D<unsigned short>) ; pusIRChannelData is (Array2D *) , so you probably want cit->second instead of cit->second() (which is trying to call your (Array2D *) as a function).

+3
source

All Articles