Implementing IDisposable on a subclass when the parent also implements IDisposable

When I just override the Dispose(bool disposing) call, it feels really strange stating that I implement IDisposable without having an explicit Dispose() function (just utilizing the inherited one), but having everything else. This is something you shouldn’t be concerned with. When you subclass an IDisposable class, all of the “Dispose pattern” plumbing is already being … Read more

Can I Override with derived types?

You can re-declare (new), but you can’t re-declare and override at the same time (with the same name). One option is to use a protected method to hide the detail – this allows both polymorphism and hiding at the same time: public class Father { public Father SomePropertyName { get { return SomePropertyImpl(); } } … Read more

Call base class method from derived class object

You can always(*) refer to a base class’s function by using a qualified-id: #include <iostream> class Base{ public: void foo(){std::cout<<“base”;} }; class Derived : public Base { public: void foo(){std::cout<<“derived”;} }; int main() { Derived bar; //call Base::foo() from bar here? bar.Base::foo(); // using a qualified-id return 0; } [Also fixed some typos of the … Read more