I just came across various overloading methods like type of parameter passed, varying number of parameters, return type etc. I just want to know that can I overload a function with following two version
//function which can modify member String& MyClass::doSomething(); //constant member function String& MyClass::doSomething() const;
Please let me know the reason behind it.
Yes you can.
If you have
The non-const version will be called. When you have
The const version will be called.