S
shaun
I have a function which does not modify a private data member which is a
map, but simply returns one value.
I'd like to make that member function const, like so:
int MapTest:: getValueAt(const int keyVal) const {
return m_myMap[keyVal];
}
BUT I get a compiler warning, I guess because the m_myMap[keyVal] has
the capability to alter m_myMap.
What is the accepted way to access the map and return a value, ensuring
that the map is not altered so the 'get' function can be const?
thanks
shaun
map, but simply returns one value.
I'd like to make that member function const, like so:
int MapTest:: getValueAt(const int keyVal) const {
return m_myMap[keyVal];
}
BUT I get a compiler warning, I guess because the m_myMap[keyVal] has
the capability to alter m_myMap.
What is the accepted way to access the map and return a value, ensuring
that the map is not altered so the 'get' function can be const?
thanks
shaun