inheritance

is this a php bug: subclasses must declare private methods with the same signature as in parent class

I am using php 5.3, and yes, there is a bug open for that, but some think this is not a bug, and this makes me wonder. abstract class A{ private function bobo(array $in){ //do something } } class B extends A{ private function bobo($shmoo,$shmaa){ //do something } } This throws an error. Shouldn't inheritance ...

Subclassing Javascript Arrays. TypeError: Array.prototype.toString is not generic

Is it possible to subclass and inherit from javascript Arrays? I'd like to have my own custom Array object that has all the features of an Array, but contains additional properties. I'd use myobj instanceof CustomArray to perform specific operations if the instance is my CustomArray. After attempting to subclass and running into some ...

Why base class destructor (virtual) is called when a derived class object is deleted?

A difference between a destructor (of course also the constructor) and other member functions is that, if a regular member function has a body at the derived class, only the version at Derived class gets executed. Whereas in case of destructors, both derived as well as base class versions get executed? It will be great to know what exac...

postgresql: using NEW.* in dynamic command for EXECUTE

hi i try to create a plpgsql trigger for postgresql 8.3 which automatically partitions a table on before insert by the id column if the destination table doesnt exist it will be created, and the insert goes there so i created the insert statement with the new table name like this exec_insert := 'INSERT INTO '||TG_TABLE_SCHEMA||'.'||T...

C++ - Superclass constructor producing an instance of a subclass

Hi. I have two classes, one of which is a subclass of another, and differs only by the fact that it contains an additional member variable to its parent. I am not using the default constructor, passing in a reference to a single object as the constructors parameter. What I would like is for the constructor of the parent to examine this ...

C#: How to determine some object type generically given instance of object

Hello all, I need to outline a little bit of background info for context. Please bear with me and I'll try to simplify my question as much as possible: I have one object that inherits from another object. We'll call the first object Fruit and the second Apple. So I've declared Apple as follows: public class Apple : Fruit { public ...

UML diagrams question regarding composition/aggregation of Base class - does the Derived class need diamond link?

Hi. If, for example, I have the following requirements: 1. Dog is an Animal 2. Zoo has Animal(s) Do I still need the 2nd diamond connector (the lower one) as shown in the image below: https://docs.google.com/drawings/edit?id=1TlnDD8LrqPo-J9_gfHdGm6Y9BpeqC8N-c6Cnc9bPwko&hl=en&authkey=CNLq5bYB Thanks. ...

How can we properly implement Python bindings of subclassed C++ objects?

I'm having an issue with a rather intricate interaction of C++ and Python that I'm hoping the community can help me with. If my explanation doesn't make sense, let me know in the comments and I'll try to clarify. Our C++ code base contains a parent classes called "IODevice" which is a parent to other classes such as "File" and "Socket"...

File/folder layout for a large C++ project with multiple levels of inheritance.

I'm in the planning stage of a relatively large (10k+ lines) project with several classes (30+) and several levels of class inheritance (5+). What is the best (or most conventional) way to lay out my project in terms of file and folder structure? Should I have one file per class? Should I have one folder per inheritance branch? Should...

How to define the default implementation of an interface in c#?

There is some black magic code in c# where you can define the default implementation of an interface. So you can write var instance = new ISomeInterface(); Any pointers? UPDATE 1: Note that is did not ask if this is a good idea. Just how was it possible to do it. UPDATE 2: to anyone seeing the accepted answer. "this should be tre...

Extend object and inherit all variables

Let's say I have an object of the class Car, with like 30 variables ranging from top speed to color. I want to make a MyCar object (class MyCar extends Car) that is basically the same thing except it stores some more information. It is not possible for me to create MyCar objects right away (since out of thousands of Car objects only a f...

[C++] Diamond sub-problem: non-multiple inheritance in side branch still require class constructor

Strange problem occurred when I tried to "solve" usual diamond problem in a usual way - using virtual inheritance: A / \* both virtual B C \ / D However my base class A doesn't have default constructor, so I was to call it manually from D. However when I try to add a class E into this diamond as C-inherited A / \* both vir...

C++ Template class inheriting another template class with a template-specified input type

Possible Duplicates: GCC problem : using a member of a base class that depends on a template argument Why does GCC need extra declarations in templates when VS does not? Why doesnt a derived template class have access to a base template class iphone compiler inherited templated base classes with passed through type not being e...

PHP - calling class that implements interface without knowing class name

I'm trying to create a PHP file that calls a function in another file. Some sample code: Interface code: interface AJAXDispatcher { static function dispatch($action); } Implementation: class myAJAX implements AJAXDispatcher { static function dispatch($action) { if ($action === "action1") { do_something(); } This s...

javascript prototype inheritance and order of definitions

hi, I'm working on a Actionscript 3.0 to Javascript-converter. I tried to find a way to circumvent the problem with the order of definitions, because it doesn't matter in AS, which package is defined first. To my surprise the following code works, although the prototype of A is defined after BA inherits from A: javascript (example outp...

Retrieving only the superclass in hibernate

I have a superclass and a subclass mapped to have a table for each class like this @Entity @Table(name="superclass_table") @Inheritance(strategy=InheritanceType.JOINED ) public class SuperClass { } @Entity @Table(name="subclass_table") public class SubClass extends SuperClass { } When I make session.createCriteria(SuperClass.cl...

Can someone explain to me why this inheiritance in javascript doesnt work?

function SuperClass() { var self = this; self.someVariable = true; } function SubClass() { var self = this; self.name = "Sub"; } SubClass.prototype = SuperClass; var sub = new SubClass(); alert("This is a sub class with name " + sub.name + " and variable " + sub.someVariable); </script> </head> <body> </bod...

C++ inheritance pattern + CRTP

am trying to understand pattern used in ublas. pattern is such: struct vector : vector_expression<vector> where vector_expression is like this: template<class E> class vector_expression { ... // no constructor or E pointer/reference in class // const E &operator () () const { return *static_cast<const E*>(this); } complete so...

protected field vs. protected method vs. implementing interface for action handlers

I have a class that represents a basic page with "go back", "go forward", and "canel" buttons in Wicket. But not all pages have all the buttons, e. g. the first page doesn't have "go back" obviously. My idea is to define a generic ActionHandler public interface ActionHandler { void perform(); } and let subclasses return the actions...

Hybrid Inheritance Example

Can anyone suggest any real life example of Hybrid inheritance? ...