inheritance

Stopping or Blocking Inheritance in C++

I would to block child classes from overriding a base method and have the child classes override a new method in a parental class. In other words, a child class of the base class blocks the base class methods and delegates to a new method that further child classes must override. I still want the base class method to be available. Her...

Interface implementation and inheritance in C#

I have some code to implement interface in C# public interface Intfc { void xyz();} public class BaseClass : Intfc { public virtual void xyz() { Console.WriteLine("In Base Class"); } } public class Derived : BaseClass { public override void xyz() { Console.WriteLine("In Derived Class"); } } st...

typedef for enum from template base class

Followup on an answer from last night - I was hoping more comments would answer this for me but no dice. Is there a way to achieve this without inheritance that does not require the cumbersome usage in the penultimate line of code below, which writes the value to cout? struct A { enum E { X, Y, Z }; }; template <class ...

C++ How can achieve this Interface configuration?

Hi, I certainly don't know how to title this question, sorry. I'm having some problems to design the following system. I need a class which will make some work, but this work can be done in a bunch of different ways, say that this work will be made through "drivers". These drivers can have different interfaces and because of that I ne...

Java inheritance

So I've been trying to find the proper way to get what should be pretty straightforward inheritance to function (the way I want ;)) and I'm failing miserably. Consider this: class Parent { public string name = "Parent"; public Parent() {}; public doStuff() { System.out.println(name); } } class Child extends Parent { ...

class containing a generic type of a child

Is there any possible way that a generic type can be used to contain a child of a base class. From the assignment given to me, I am to create something similar to the following in structure. template <class T> class Fruit { private: int count; int location_id; T type; public: virtual void displayInfo(); }; class Ap...

ASP.Net - Can I Access My BasePage Properties From Within Markup?

I want to be able to extend the System.Web.UI.Page class and then easily access those properties from the Markup. I know I can do it from the codebehind, but is it possible from the Markup? Take the following class. public class MyBasePage : System.Web.UI.Page { public bool DoesThisWork { get; set; } } Then I want to be able to ac...

CSS Style inheritance/overloading

Hello! I have a web page that, at a certain point, displays a navigation bar which is nothing more than a list (ul) of a elements. Most of the style rules for said a elements is common. The only part that should change is the image to show which can be guessed from the id tag of each li element of the list. So here's the question: Is ...

Can child templates stored in a base class array, use an overloaded virtual function?

In hope to simplify a homework problem dealing with inheritance, I thought it might be better to use polymorphism to accomplish the task. It isn't required, but makes much more sense if possible. I am, however, getting symbol errors making it work as I thought it should or just the base class definition is called. I want the overloade...

Eval() and base class properties

I have class Foo which defines property Id. Class Bar inherits from Foo (class Bar : Foo). If I assign a List<Bar> to Repeater.DataSource then use Eval("Id") in the ItemTemplate, the following exception is thrown: DataBinding: 'Bar' does not contain a property with the name 'Id'. Any way around this? Id is a valid property of Bar...

pygame: custom classes inheriting from pygame.Surface

Hello all, I'm playing with pygame for the first time (and am kind of a newb about python in general), and wondering if anyone could help me with this... I'm making a little shootem-up game and want to be able to create a class for bad guys. My thought was that the class should inherit from pygame.Surface, but that's giving me all kinds...

Is possible to know the path of the file of a subclass in python?

I have a plugin system. The plugins subclass from a common ancestor... ad look like this: -- SDK --- basePlugin.py -- PLUGINS --- PluginA ---- Plugin.py ---- Config.ini --- PluginB ---- Plugin.py ---- Config.ini I need to read the info of Config.ini in basePlugin.py __init__. CUrrently in each plugin I do: class PluginA(BaseSync): ...

Howto move from object based language to server side Node.js Javascript for big projects?

Hi there, I've decided to get used to using Javascript as my server sided (I'm using Node.js) language to setup a webserver, create server deamons and a lot more. This is a rather big project, which means that I have to get used to the language and get myself an optimal setup before actually starting to avoid overhead and unneeded hassl...

Calling Parent methods and accessing private variable in a Parent class?

I'm trying to get the following code to work, but I can't find good-enough documentation on how C++ handles public vs. private inheritance to allow me to do what I want. If someone could explain why I can't access Parent::setSize(int) or Parent::size using private inheritance or Parent::size using public inheritance. To solve this, to ...

accessing protected members of superclass in C++ with templates

Why can't a C++ compiler recognize that g() and b are inherited members of Superclass as seen in this code: template<typename T> struct Superclass { protected: int b; void g() {} }; template<typename T> struct Subclass : public Superclass<T> { void f() { g(); // compiler error: uncategorized b = 3; // compiler error: unr...

Inherited C# Class Losing "Reference"

I have a partial class using an interface because I can’t inherit what was an original abstract class due to the other partial class being auto-generated from Entity Framework 4 and therefore already inheriting ObjectContext. I have the following for my partial class: namespace Model { using Microsoft.Practices.EnterpriseLibrary.Va...

python class inherits object

Is there any reason for a class declaration to inherit object? I just found some code that does this and I can't find a good reason why. class MyClass(object): # class code follows... The code is using swig for binding some C code to Python, if that's relevant. ...

How to see if a type implements an interface in VB.Net?

I need to know if a Type implements an interface. Dim asmRule As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Rule.dll")) For Each typeAsm As System.Type In asmRule.GetTypes If TypeOf typeAsm Is Rule.IRule Then 'that does always return fa...

How do I create a method or property in C# that is public, yet not inheritable?

Here is an example. I have two classes, one inherited, and both have a function with the same name, but different arguments: public class MyClass { //public class members public MyClass() { //constructor code } public void Copy(MyClass classToCopy) { //copy code } } public class InheritedC...

Base class's destructor called without destroying the base class!

#include<iostream> using namespace std; class A { public: int i; A() {cout<<"A()"<<endl;} ~A() {cout<<"~A()"<<endl;} }; class B:public A { public: int j; B(): j(10) { this->i=20; this->~A(); } }; int main() { B abc; cout<<"i="<<abc.i...