Relative Content

Tag Archive for c#inheritance

Getting Undefined Reference to base bvtable with simple example

class Base { int m_var; public: virtual void mf_0() = 0; //The contract. The compulsory Customization virtual void mf_1(); //The customizable “default behaviour” int m_f2(); // the invariant. Redefining this in derived class would mean // the derived class is-not-really-a base class .. or that this // non virtual function should really be virtual, i.e. […]

Where to place methods in inheritance hierarchy when the overlap of use is complicated (C#)?

Let’s say I have a base class “base” and three classes that inherit it “A”, “B”, and “C”. Class A needs access to method1, and method2. Class b needs access to method2, and method3. Class c needs access to method3 and method4. Should all of these methods be defined in the base Class? It seems wrong for each derived class to have access to methods that they do not need. Is there a better solution that I’m not thinking of?

Where to place methods in inheritance hierarchy when the overlap of use is complicated (C#)?

Let’s say I have a base class “base” and three classes that inherit it “A”, “B”, and “C”. Class A needs access to method1, and method2. Class b needs access to method2, and method3. Class c needs access to method3 and method4. Should all of these methods be defined in the base Class? It seems wrong for each derived class to have access to methods that they do not need. Is there a better solution that I’m not thinking of?