inheritance

Is there a way to have PHP subclasses inherit properties (both static and instance)?

If I declare a base class as follows: abstract class Parent { protected static $message = "UNTOUCHED"; public static function yeah() { static::$message = "YEAH"; } public static function nope() { static::$message = "NOPE"; } public static function lateStaticDebug() { return(static...

Is it possible to get an instance of every class that inherits from an interface?

I have a small project that I'm making, and I'm trying to figure out if it's possible to get an instance of every class that inherits from a particular interface. Here's a simplified example of what I'm trying to accomplish: public interface IExample { string Foo(); } public class Example1 : IExample { public string Foo() ...

Inheritance in Javascript - protoyping not in definition-part?

Hi I am currently switching from AS3 to Javascript. I still have some trouble with understanding inharitance-concepts. What I do not understand is why the following code is not working properly: Base = function () { this.coolVar = "great"; } SmallControl = function () { // Inheritance: this.prototype = new Base(); ...

CStatic Custom Control

I am trying to create a custom CStatic control in vc++ and have a few problems. I originally was just using a CStatic control with the SS_BLACKRECT style. This was good for the situation until I needed to display an image over the control on demand. I figured out all the logistics behind actually drawing the image onto the control but I ...

Is there a Form method I can override after all controls are created but visible at design time in .NET?

I'm looking for a method that I can override in my sub classed Form where all the controls inside the Form are already created and visible at design time? I've tried OnHandleCreated() and it works as I expected at run time because I need to loop through all controls in a specific Form and do something to do them. However, I would like t...

Is this ASP.NET Inherited Shared Function practice acceptable?

I have a bunch of different forms that I would like to create a base MustInherit class for. One function I would like them all to contain is a shared function called GetForms(). I know that you can't declare a shared function MustOverride so I did the following in my abstract class: Public Shared Function GetForms() As List(Of OrderForm...

C#.NET - How Can I Get typeof() to Work With Inheritance?

I will start by explaining my scenario in code: public class A { } public class B : A { } public class C : B { } public class D { } public class Test { private A a = new A ( ) ; private B b = new B ( ) ; private C c = new C ( ) ; private D d = new D ( ) ; public Test ( ) { // Evaluates to "false" ...

Catching exceptions polymorphically

Here is main(): int main() { B b(1,"two","three"); try { f1(b); } catch(B& b_ref) { cout<<"Caught B&"<<endl; b_ref.print(); } catch(A& a_ref) { cout<<"Caught A&"<<endl; a_ref.print(); } system("pause"); return 0; } Here is f1(): void f1(A& subjec...

Why don't structs support inheritance?

I know that structs in .NET do not support inheritance, but its not exactly clear why they are limited in this way. What technical reason prevents structs from inheriting from other structs? ...

LinqToSQL and inheritance mapping

Hello I've been googling around on L2S inheritance, and I think I have a fair idea of the limitations/what I have to do, but just looking for some confirmation from the community. I have a REAL BASIC setup here: public abstract class BusinessObject { public int Id { get; set; } } [Table] public class Customer: BusinessObject { } ...

ID's on parent and child classes in NHibernate

Working on a project where I have more or less carte blanche to modify the database schema and object model (nice position to be in. (c:) Suppose I have a trivial inheritance tree like: class Parent { public int ID { get; set; } } class Child : Parent { // some fields } Is it better to have a database schema where the child ...

What techniques/strategies do people use for building objects in C (not C++)?

I am especially interested in objects meant to be used from within C, as opposed to implementations of objects that form the core of interpreted languages such as python. ...

WPF control inheritance

I've read in a blog the following sentence: The first rule of WPF: Avoid control inheritance. I've seen similar things in other places as well. However, I fail to understand the logic. Moreover, I see suggestions here in StackOverflow that involves inheriting WPF controls (see the replies to my previous question for example). I...

How to use base class's constructors and assignment operator in C++?

I have class B with a set of constructors and an assignment operator. class B { public: B(); B(const string & s); B(const B & b){(*this) = b;}; B & operator= (const B & b); private: virtual void foo(); // and other private member variables and functions } I want to create an inheriting class D that will just override the...

Why can I not add a set accessor to an overriden property?

In a base class I have this property: public virtual string Text { get { return text; } } I want to override that and return a different text, but I would also like to be able to set the text, so I did this: public override string Text { get { return differentText; } set { differentText = value; } } This however does n...

ASP.NET Page inheritance

Hi Looking for advice on the net but not getting very far, so I thought I would ask for some advice. I've seen it done, so know what I want to do, but looking I can work out how it was done What I want to do, is allow users to modify the layout of an ASPX file, so that they can use it as a letter template, moving address lines, format ...

C++ Overriding Methods

I can't figure out what is up with this. I have a Scene class that has a vector of Entities and allows you to add and get Entities from the scene: class Scene { private: // -- PRIVATE DATA ------ vector<Entity> entityList; public: // -- STRUCTORS --------- Scene(); // -- PUBLIC METHODS ---- void ad...

Method parameter can be a class or interface, little confused

Hi, If I have a class: public blah { } Then I have another class that inherits blah" public ablah : blah { } Can I do this then? public class Someservice { public bool SomeBlah(blah b) { } } Could I call it the service with either classes blah or ablah? ie. Someservice s1 = new Somesercie(); s1.SomeBlah(new blah());...

Hibernate 'tableless' enum mapping?

I am dealing with the following scenario: We use table-per-subclass inheritance, meaning the concrete tables' primary keys are foreign key references on the abstract table. Superclass is Product, subclasses are Book, DVD, AudioCD, ... Now in the Java superclass, say Product.java, we have an enum of the types of products: book, dvd, mu...

How to cast 'Class A' to its subclass 'Class B' - Objective-C

I'm using a framework which defines and uses 'ClassA', a subclass of NSObject. I would like to add some variables and functionality so naturally I created 'ClassB', a subclass of 'ClassA' Now my problem is this. Many of the methods within this framework return instances of 'ClassA' which I would like to cast to my subclass. For exampl...