inheritance

Scala : parameterize a type with one of its inner types

I would like to parameterize a type with one of its subclasses. Consider the following: class DataLoader { class Data { /* data specifics to this data loader */ } def getData : Data /* and so on */ } Now I want to make this loader able to asynchronously retrieve data from the network. One of the options is to have it subclass Call...

Codeigniter and Multiple Inheritance?

Wondering if this is even possible or a limitation of PHP, googling around seems to be the case but maybe I'm missing a clever solution here. Hopefully this will make sense. Right now I have two portions to my site, an admin and client side. I have been able to split it into two controllers(admin and client) that inherit from a base M...

why interface can not implement another interface in java?

What I mean, interface B; interface A extends B; allowed interface A implements B; not allowed I googled it and I found this -> Implements denotes defining an implementation for the methods of an interface. However interfaces have no implementation so that's not possible. http://www.coderanch.com/t/410331/java/java/interface-imple...

In EJB3, How to implement inheritance for Session Bean?

We want to achieve following things: Create Abstract Stateless session bean Create stateless bean by extending the above bean. In Service class, based on type container will inject appropriate ejb bean ...

In C++, how to initialize static member of a private class declared inside a Singleton template ?

Ok, I should simply tell that I want to make a base Singleton class that I can inherit from, and the way I want to achieve that is by a template. In order to avoid memory leaks, I do not use directly a pointer to the instance, but a private class that will handle deleting the pointer. Here is my actual code (not working) : template <t...

WPF Style with no target type?

Hi, How can I have a WPF style that has no target type ( one that can be applied to all objects) ? <Style x:Key="Basic" TargetType="???"> <Setter Property="FontFamily" Value="Tahoma"/> <Setter Property="FontSize" Value="12"/> </Style> I want to base all other styles on this "basic" style. Regards, MadSeb ...

java subclass have method to return its class

Ok, maybe this is a stupid question. But i'm just wondering if this can be done in java. abstract public class ParentClass<T> { abstract public T getTest(); } in the subclass public class SubClass extends ParentClass<MyObject> { public MyObject getTest() { // I can return the object with class MyObject return null; } ...

g++ typedef templates in inheritor class

simplifying my problem we can consider: template <class T> class Base{ typedef typename std::pair<T, T> pair; }; template <class T> class Inheritor : public Base<T> { pair *p; // mean that we want to use constructor of std::pair. // say: std::pair withou argument list Inheritor<T>::pair *p...

Form designer breaks on generic abstract UserControl

I have a generic abstract UserControl class, SensorControl, which I want all my sensor control panels to inherit from. The problem When attempting to design the EthernetSensorControl (one of my inherited UserControl forms, from within Visual Studio, the following error is displayed in the form designer: The designer could not be show...

Is possible to inherit from SPWeb?

Hi, Is possible to inherit from SharePoint classes such like: SPWeb, SPList etc. or this classes are sealed? I couldn't find right answer. Chris ...

How to add constraints on inherited properties in a grails domain sub-class

Here's what I'd like to do: class A { String string static constraints = { string(maxSize:100) } } class B extends A { static constraints = { string(url:true) } } So class A should have some constraints and B should have the same plus additional constraints on the same property. I couldn't get that to work though a...

Defining an object's behavior using polymorphic inheritance

Hi all! Today I was faced with a challenge to create different behaviors for my shopping cart model. That's because the owner of the online shopping wanted to create some promotions like buy 1, get 5 or get 25% discount + some extra stuff, etc... I thought of doing it with polymorphic inheritance, where my Cart model will only hold the...

In Moose, how can I tell whether one object's class is a subclass of another object's class?

Suppose I have two objects $obj1 and $obj2 that are both instances of Moose classes. I want to find out which of the following applies: $obj1's class is the same as $obj2's; $obj1's class is a subclass of $obj2's; $obj1's class is a superclass of $obj2's; Neither object's class is a subclass of the other's. How can I do this? ...

Java: generics inheritence confusion

Hey, Imagine we have following classes: public interface MyInterface<T> { List<T> getList(T t); } abstract class BaseClass<T extends Number> implements MyInterface<T> { @Override public List<T> getList(Number t) { return null; } } class ChildClass extends BaseClass<Integer> { @Override public List<Inte...

C#: override a property of the parent class

I have a class that inherits from X509Certificate2. I want the NotAfter property to be in UTC rather than local time. I'm pretty new to C# and was wondering if what I have below is the best way of doing it? internal class Certificate : X509Certificate2 { public new DateTime NotAfter { get { return base.NotAfter.ToUnive...

How can I know that an instance of a model was created by an instance of a child model?

Hi, I've got a model Child inheriting from a (non abstract) model Parent. For a given instance parent of Parent, how can I know if it's a Child? If it is, parent.child returns the child, but otherwise it returns a DoesNotExist exception. Is a try/except the only way to check that? Thanks jul # EDIT I've just find the same quest...

PHP - Getting child class when executing parent function?

Hi, I don't think I am being silly here. class Parent { function load($function) { if (method_exists(__CLASS__, $function)) { // Load Function } } } Class Child extends Parent { function foo() { } } $this->Child->load('foo'); The problem is that __CLASS__ is returning 'Parent'. How do I get it to return Child?...

What Methods Can Be Employed For Using Composition Over Inheritance?

I have a web application (in ASP.NET MVC) with a Quotations controller. This controller can handle multiple Quotation types, MotorQuotation, PropertyQuotation, etc... Currently it is using inheritance i.e. a Quotation model and it's children, to model the domain. The various children classes have differences in the data they store and n...

C++ Inheritance Question

In the file test.cpp, I have this: template <typename T> class A { public: A(int a){}; virtual ~A(); private: }; class B : public A<int> { public: B(int a):A(a){}; virtual ~B(); private: }; int main() { return 0; } When I compile it, I get this: jason@jason-linux:~/Documents/ECLibrary$ g++ -g -Wall -Wextra -pedantic-err...

Method/Constructor Overloading with Super/Sub types

I have some questions as to which overloaded method would be called in certain cases. Case 1: public void someMethod(Object obj){ System.out.println("Object"); } public void someMethod(InputStream is){ System.out.println("InputStream"); } public void someMethod(FilterInputStream fis){ System.out.println("FilterInputStream...