rewrite const property through overloading
Hello everyone,
I have tried compiler allows to change const property of an overloaded method. Here is my proof of concept code.
My question,
1. is it good code or good practice?
2. It yse in (1), are there any practical usage of this type of "overloading"?
Code:
class Base {
public:
const int foo() {return 200;};
};
class Derived : public Base {
public:
int foo() {return 100;};
};
int main()
{
Base b;
Derived d;
int rtn = b.foo();
rtn = d.foo();
return 0;
}
thanks in advance,
George