Hi there - I'm mainly a C+Java+Python+Lisp programmer, and though I've done a fair bit of C++ in the past I definitely don't consider myself an expert, so was wondering if someone with more detailed knowledge could help me out here.
I'm using Qt for a project, and found myself wanting to use operator[] on a QMap. I tootle along to the QMap online documentation to see if there's anything I need to be aware of and find the following two function signatures for operator[] (here):
Code:
T & QMap::operator[] ( const Key & key )
const T QMap::operator[] ( const Key & key ) const
One returns a modifiable reference to the T indexed by key, the other returns a const copy, and I'd quite like to know which one I'm getting!
Now, I thought you could only overload methods based on their arguments - but clearly that's not what's distinguishing these two. I doubt it's based on return type, so I'm guessing it's somehow based on the const-"ness" of the object on which I'm using these methods? Am I close? What am I missing here?