jacknad jacknad - 3 months ago 33
C++ Question

How to fix 'unresolved overloaded function type?'

This is the class

class Channel
{
public:
Channel(int channelNumber, ChannelType channelType);
};


and this is the map

map<int, Channel> m_Channel(int, ChannelType);


Why does attempting to add a
Channel
to the map like this

m_Channel[channelNumber] = Channel(channelNumber, channelType);


cause this compile error?


error: invalid types
‘<unresolved overloaded function type>[int]’
for
array subscript


int
seems like a perfectly valid type for an array subscript.

Answer

This line

map<int, Channel> m_Channel(int, ChannelType);

declares a function named m_Channel that takes an int and a ChannelType and returns a map<int, Channel>. I assume you want it to be a member variable instead.

map<int, Channel> m_Channel;

See https://en.wikipedia.org/wiki/Most_vexing_parse

Comments