|
Override Private: msg#00276gcc.help
I saw a trick to overrides the member function's private specification. It is as following: class Base { private: virtual void fun(){ cout << "Base" << endl;}; }; class Derived:private Base { public: void fun() { cout << "Derived" << endl;}; }; int main() { Derived* bp = (Derived *) new Base; bp->fun(); return 0; } And, this will give "Base" as the Base::fun() is run. Is this an intentional behavior or just the compiler gets confused here? If it is intentional, any justification for this? Thanks for your comments. |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Where's ".div" implemented?: 00276, Nick Patavalis |
|---|---|
| Next by Date: | Re: Override Private: 00276, John Love-Jensen |
| Previous by Thread: | Where's ".div" implemented?i: 00276, Nick Patavalis |
| Next by Thread: | Re: Override Private: 00276, John Love-Jensen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |