jacknad jacknad - 1 year ago 138
C++ Question

How to fix 'unresolved overloaded function type?'

This is the class

class Channel
Channel(int channelNumber, ChannelType channelType);

and this is the map

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

Why does attempting to add a
to the map like this

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

cause this compile error?

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

seems like a perfectly valid type for an array subscript.

Answer Source

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