inheritance

Right design of my application - is inheritance right choice?

I have some simple scheduling of various events in my application and I used this class hierarchy: abstract class ScheduledEvent { public DateTime When{ get; set; } public abstract void Trigger(); } class WhateverEvent : ScheduledEvent { public override void Trigger(); } class AnotherEvent : ScheduledEvent { public overr...

When inheriting a class can you generate all the override functions and methods?

I'm adding a new class which inherits from the the RoleProvider, I then need to add all the differant override functions. Is there a quick way to generate them via the IDE? Hope that makes sense. Thanks ...

NHibernate Inheritance Mapping

I know in NHibernate you can have inheritance mappings, and I know you can have table-per-class, table-per-subclass and table-per-concrete-class but they don't quite fit the scenario I have. Basically what I want is to be able to have a base class called product that looks like this: public class BaseProduct { public virtual int ...

MSDN: How can I see what inherits/implements a class/interface?

One thing I really, really miss from Javadoc is the ability to see which classes inherit the class you're looking at. So if you are looking at an abstract class (such as List) then you would be able to see all classes that inherit/implement the class/interface you're looking at. Is this available in the MSDN and I'm just missing it or is...

private inheritance

I dont completely understand this: class Base { public: Base() { cout<<"Base" << endl; } virtual void call() { cout<<"Base call" << endl; } }; class Derived: private Base { public: Derived() { cout<<"Derived" << endl; } }; int main(void) { Base *bPtr = ne...

How can I compare an object with the parent class in php?

I want to compare the class of an object with the current class, and in inherited methods to refer to the parent class. This is the only way I can think of doing it: class foo { function compare($obj) { return get_class($obj) == get_class(new self); } } class bar extends foo { } $foo = new foo; $foo->compare(new foo); //true $foo->comp...

Can !important rules be used in IE's CSS expressions?

Firstly, I know that CSS expressions are defunct and wrong in so many ways, and also to avoid using !important where possible. This is for a special case stylesheet. In Short My question is... Is there any way for a CSS expression to set the !important flag? E.g. this doesn't work: a { color:expression('red !important'); } [Edit: t...

Impossible to inherit from this object?

Following up on this question, people have suggested I go with "option 3" which might look like this: class b2Body { private: b2Body() {} friend class b2World; }; class Body : public b2Body { private: Body() {} friend class World; }; class b2World { public: b2Body *CreateBody() { return new b2Body; } }; class World : public b...

Django inheritance: how to have one method for all subclasses?

I have a model BaseModel and several subclasses of it ChildModelA(BaseModel), ChildModelB(BaseModel), ... using multi-table inheritance. In future I plan to have dozens of subclass models. All subclasses have some implementation of method do_something() How can I call do_somthing from a BaseModel instance? Almost identica...

Inheritance and Overriding Methods/Properties

If I have two classes, one which inherits from the other and I use the same method/property name in both, how can I make that method call the subclass regardless of whether the current object has been cast back to it's base class. For example (extraneous parts omitted): public class MyBase { public int GetNumber() { return 1; ...

Instantiating objects and object members

For some reason the following doesn't crash like my program does, but I'm pretty sure it's similar in design. For one, the output's not correct. It outputs something similar to: 0x537ff4 5471612 While the main program outputs (nil) for the pointer address. The key to the problem might be display_ in Drv. Here's the code: #include <...

Scala: how to inherit a "static slot"?

Well, I'm learning Scala so this question may be too basic for most people. In Java I can have a static slot (function or variable) in a class, and then I will have that slot in inherited classes too. In Scala I don't have static slots, but I have companion objects. But I'm finding out that those objects are not part of the inherited c...

Is there a "SELF" type in scala that represents the current type?

I'm learning Scala and there is a thing that I can't find out about the language: Some time ago I was very comfortable programming in Lisaac, and in Lisaac I could write a class PERSON with a slot list:ARRAY[SELF], which was equivalent to have list:ARRAY[PERSON], since SELF is the type of the object where that slot is. But by using SEL...

Performing Inheritance in Javascript

Now while i know that you can not perform inheritance like you would in C# ,but i have seen mentions about it arround the net that it is kind of possible. If its not possible using plain javascript then would it be possible using Ext JS and if so how. ...

Returning incorrect type from a function.

Ok, I was scanning through some code yesterday and I saw this, Code: public class MyBaseClass { public string Field0() { return string.Empty; } } public class MyClass : MyBaseClass { public string Field1() { return String.Empty; } } Pretty si...

Inherited method needs one more parameter

I have a parent class with several children. One of the children, has one overridden method that, for its particular internal usage, needs one more parameter. I don't want to change the method's signature because the overridden method in the other children does not need this parameter, also, I don't want to add a class property because i...

Why subclass NSObject?

What is the purpose/use of NSObject in Objective-C? I see classes that extend NSObject like this: @interface Fraction : NSObject In C++ or Java, we don't use any variables like NSObject even though we have preprocessor directives and import statements in both Objective-C and Java. Why do classes explicitly inherit from NSObject in O...

Subclassing Inner Class from Outer Class versus other Inner Class

I am befuddled why this is allowed public class Foo { class Bar extends Foo { } } Yet this is not allowed public class Foo { class Bar extends Foo { } class Fooey extends Bar { } } The compiler informed that it can not reference Fooey.this before supertype constructor has been called. And this is allowed ...

Accessing asp.net Profiles from App_Code

I am creating a base class from which specific pages are going to be derived. That is, instead of inheriting my pages from System.Web.UI.Page, they're inheriting from MyPage (which in turn, inherits from System.Web.UI.Page). However, I can't seem to be able to access the Profile property. Even though they both inherit from Page, I can o...

How can I call a masked function in C++?

Let's say I have this C++ code: void exampleFunction () { // #1 cout << "The function I want to call." << endl; } class ExampleParent { // I have no control over this class public: void exampleFunction () { // #2 cout << "The function I do NOT want to call." << endl; } // other stuff }; class ExampleChild : pub...