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;
}
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With