Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

pointers

map

everyone! I maintain a group of channel data in a map container, from which an individual channel data can be accessed by its channle name. With regards to this, I write a simple function GetIRChannelData (please see the following code). When compliing, the statement pusIRChannelData = cit->second(); throwed an error, which read

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

All the function to do is nothing but to search for a given channel name/ID in the map container, and assign it data pointer to a temporal pointer if found. Would you please show me what's wrong?

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;
}
like image 495
GoldenLee Avatar asked Jul 03 '11 04:07

GoldenLee


2 Answers

The error message is pretty clear... you call a function that doesn't exist. map::iterator points to a std::pair, which has two member objects, first and second. Note that these are not functions. Remove the () from the line in question and the error should go away.

like image 167
Dennis Zickefoose Avatar answered Nov 19 '22 10:11

Dennis Zickefoose


It looks like cit->second doesn't identify a function pointer. The definition of your iterator claims it's a pointer to (Array2D<unsigned short>); pusIRChannelData is an (Array2D *), so you probably want cit->second instead of cit->second() (which tries to invoke your (Array2D *) as a function).

like image 4
geekosaur Avatar answered Nov 19 '22 10:11

geekosaur