inheritance

IQueryable pipline, with inheriting ORM model

I am trying to implement a media library system, and I started out my design from the POCO. I am planning to decouple the actual data access from the object so that, I may persists the same object in XML or SQL. What I have in the design is: public abstract class MediaBase {} public class Image : MediaBase {} public class Movie : Medi...

Can simple JavaScript inheritance be simplified even further?

John Resig (of jQuery fame) provides a concise and elegant way to allow simple JavaScript inheritance. It was so short and sweet, in fact, that it inspired me to attempt to simplify and improve it even further. I've modified Resig's original Class.extend function such that it passes all of his inheritance tests (plus a few more), and al...

Calling private parent class method from parent class (django)

I want to call a redefined private method from an abstract parent class. I am using django if that matters. class Parent(models.Model): def method1(self): #do somthing self.__method2() def method2(self): pass # I also tried calling up a prent method with super class child(Parent): def method1(sel...

How to force multiple Interfaces to include certain the same properties?

I am trying to figure out a way to force all of my Interfaces to include properties of the same name/type. For example: I have two Interfaces; IGetAlarms and IGetDiagnostics. Each of the Interfaces will contain properties that are specific to the Interface itself, however I want to force the two Interfaces (and all other Interfaces that...

I'm getting an error in my Java code but I can't see whats wrong with it. Help?

The error i'm getting is in the fillPayroll() method in the while loop where it says payroll.add(employee). The error says I can't invoke add() on an array type Person but the Employee class inherits from Person so I thought this would be possible. Can anyone clarify this for me? import java.io.*; import java.util.*; public class Pa...

Maven: trying to get my submodule's poms to NOT inherit a plugin in the parent

My project has a parent pom and several submodule poms. I've put a plugin in the parent that is responsible for building our installer distributables (using install4j). It doesn't make sense to have this plugin run on the submodules, so I've put false in the plugin's config, as seen below. The problem is, when I run mvn clean install ins...

Binding functions of derived class with luabind

I am currently developing a plugin-based system in C++ which provides a Lua scripting interface, for which I chose to use luabind. I'm using Lua 5 and luabind 0.9, both statically linked and compiled with MSVC++ 8. I am now having trouble binding functions with luabind when they are defined in a derived class, but not its parent class. ...

Calling Subclass Method in Java

Given the following situation (UML below), If Y has the method: public void PrintWs(); and X has: ArrayList <P> myPs = new ArrayList(); Y y = new Y(); Z z = new Z(); myPs.add(y); myPs.add(z); How do I loop through each myPs object and call all Ys PrintWs (without using instanceof)? http://starbucks.mirror.waffleimages.com/files/...

Java generics parameters with base of the generic parameter

Hello, I am wondering if there's an elegant solution for doing this in Java (besides the obvious one - of declaring a different/explicit function. Here is the code: private static HashMap<String, Integer> nameStringIndexMap = new HashMap<String, Integer>(); private static HashMap<Buffer, Integer> nameBufferIndexMap = ...

How to know the base type of an inherited generic type ?

Consider this code : class MyClass<T> { } class AnotherClass : MyClass<String> { } When I look at the BaseType property of the AnotherType Type, it says that it is Object, where I expected to see the generic MyClass type. Is there a way to know that AnotherClass inherits MyClass ? EDIT : The problem was that the MyClass type was ac...

is multiple inheritance a compiler writers problem? - c++

i have been reading about multiple inheritance http://stackoverflow.com/questions/225929/what-is-the-exact-problem-with-multiple-inheritance http://en.wikipedia.org/wiki/Diamond_problem http://en.wikipedia.org/wiki/Virtual_inheritance http://en.wikipedia.org/wiki/Multiple_inheritance But since the code does not compile until th...

Conversion of pointer-to-pointer between derived and base classes?

Regarding the following C++ program: class Base { }; class Child : public Base { }; int main() { // Normal: using child as base is allowed Child *c = new Child(); Base *b = c; // Double pointers: apparently can't use Child** as Base** Child **cc = &c; Base **bb = cc; return 0; } GCC produces the foll...

How do you make a private member in the base class become a public member in the base class?

Consider the following code: class Base { void f() { } }; class Derived: public Base { public: }; What can you change in the derived class, such that you can perform the following: Derived d; d.f(); If the member is declared as public in the base class, adding a using declaration for Base::f in the derived class public sect...

In C#, can I hide/modify accessors in subclasses?

I'm not even sure what this principle is called or how to search for it, so I sincerely apologize if it has been brought up before, but the best way to do it is with an example. class Properties { public string Name { get; set; } } class MyClass { class SubProperties: Properties { public override Name { ...

PHP syntax for referencing self with late static binding

When I learned PHP it was pretty much in procedural form, more recently I've been trying to adapt to the OOP way of doing things. Hoever the tutorials I've been following were produced before PHP 5.3 when late static binding was introduced. What I want to know is how do I reference self when calling a function from a parent class. For...

C#: Specify that a function arg must inherit from one class, and implement an interface?

I'm making a game where each Actor is represented by a GameObjectController. Game Objects that can partake in combat implement ICombatant. How can I specify that arguments to a combat function must inherit from GameObjectController and implement ICombatant? Or does this indicate that my code is structured poorly? public void ComputeAtta...

C++ list<T>::iterator cant be used in derived class template

g++ compiler gives this error: expected `;' before 'it' template <typename T> class myList : public std::list<T> { public: void foo () { std::list<T>::iterator it; // compiler error as above mentioned, why ??? } }; Thanks. ...

Best way to re-use the same django models and admin for multiple apps

Given a reference app ( called guide), how can I create additional apps that will reuse the same model/admin/views than guide - the motivation behind is to be able to individually control each subapp. guide guideApp1 exact same models/admin/views than guide guideApp2 exact same models/admin/views than guide in the Admin site, I...

How do you use the LINQ to SQL designer to generate accessor methods for subclasses?

Above is the LINQ to SQL designer view for my data context. Below is the relevant code that the designer generates: Accessor for the abstract ActivityBase class: public System.Data.Linq.Table<ActivityBase> ActivityBases { get { return this.GetTable<ActivityBase>(); ...

Class Decorators, Inheritance, super(), and maximum recursion

I'm trying to figure out how to use decorators on subclasses that use super(). Since my class decorator creates another subclass a decorated class seems to prevent the use of super() when it changes the className passed to super(className, self). Below is an example: def class_decorator(cls): class _DecoratedClass(cls): def ...