inheritance

Inheriting from protected classes in C+++

Suppose I have the following declaration: class Over1 { protected: class Under1 { }; }; I know that I could do the following: class Over2 : public Over1 { protected: class Under2 : public Under1 { }; }; But is there a way to declare Under2 without Over2? Since you would have to exte...

How can I keep a class from being inherited in C#?

In java, I could do this with the 'final' keyword. I don't see 'final' in C#. Is there a substitute? ...

How can you inherit from a sealed class using reflection in .Net?

Before you start firing at me, I'm NOT looking to do this, but someone in another post said it was possible. How is it possible? I've never heard of inheriting from anything using reflection. But I've seen some strange things... ...

C# Can I Override with derived types?

Hello, As far as i know it is not possible to do the following in C# 2.0 public class Father { public virtual Father SomePropertyName { get { return this; } } } public class Child : Father { public override Child SomePropertyName { get { return this;...

How can I prevent a base constructor from being called by an inheritor in C#?

I've got a (poorly written) base class that I want to wrap in a proxy object. The base class resembles the following: public class BaseClass : SomeOtherBase { public BaseClass() {} public BaseClass(int someValue) {} //...more code, not important here } and, my proxy resembles: public BaseClassProxy : BaseClass { public ...

Java: Newbie-ish inheritance question...

Suppose I have a base class B, and a derived class D. I wish to have a method foo() within my base class that returns a new object of whatever type the instance is. So, for example, if I call B.foo() it returns an object of type B, while if I call D.foo() it returns an object of type D; meanwhile, the implementation resides solely in t...

Design of inheritance for Validate interfaces

I've never been so good at design because there are so many different possibilities and they all have pros and cons and I'm never sure which to go with. Anyway, here's my problem, I have a need for many different loosly related classes to have validation. However, some of these classes will need extra information to do the validation. I ...

How to use JSON to create object that Inherits from Object Type?

I know how to use JSON to create objects, but there doesn't seem to be away to use JSON to create an object that is of a specific object type. Here's an example of an Object and creating an instance of it: Person = function() { }; Person.prototype = { FirstName: null, GetFirstName: function() { return this.FirstName; ...

What does it mean that Javascript is a prototype based language?

One of the major advantages with Javascript is said to be that it is a prototype based language. But what does it mean that Javascript is prototype based and why is that an advantage? ...

Inheriting from an ASP.NET web control: "Element <name> is not a known element"

I'm attempting to create a custom calendar control that inherits from ASP.Net's built in calendar user control. the code-behind file for my control looks like this: public partial class WeeklyEventsCalendar : Calendar { protected void Page_Load(object sender, EventArgs e) { } } and compiles fine. However, when I try t...

How do I use or resolve issues with visual form inheritance in Delphi?

I've been working on a project in Delphi 7 where I wanted to have forms inherit components from other forms. I was able to get this working, but came across the following issues (and I'm going to post the solutions to hopefully help others in the future): In the .pas file of a form, I would change the form to inherit from some other fo...

Polymorphism vs Inheritance (example problem case)

I am still trying to wrap my head around design patterns and for the second time I'm coming up against the same problem that seems to be crying out for a pattern solution. I have an accounts system with multiple account types. We have restaurant, hotel, service_provider, and consumer account types. Im sure there will be more business a...

Should C# include multiple inheritance?

I have come across numerous arguments against the inclusion of multiple inheritance in C#, some of which include (philosophical arguments aside): Multiple inheritance is too complicated and often ambiguous It is unnecessary because interfaces provide something similar Composition is a good substitute where interfaces are inappropriate ...

Inheritance trees and protected constructors in C#

Given the following inheritance tree, what would be the best way of implementing it in a way that works? abstract class Foo<T> : IEnumerable<T> { public abstract Bar CreateBar(); } class Bar<T> : Foo<T> { // Bar's provide a proxy interface to Foo's and limit access nicely. // The general public shouldn't be making these tho...

C# Inheritance

I had a coworker see this the other day and I'm not quite sure why this happened. Can anyone explain it? We have class A: using System; using System.Data; public class A { protected DataTable _table; public A() { } } We have class B that inherits from class A (assume there in the same namespace): using System; public cla...

.NET inheritance with generic interfaces

Hallo i am currently playing around with castle projects ActiveRecord and the remoting facility. my current problem is that i need the find a way the implement the save sub from IBaseRepository in my address class and i dont know how. here is my current code, VS tells me on the line "implements IAddress" that i have to implement Sub Sa...

Java: At runtime, find all classes in app that extend a base class

I want to do something like this: List<Animal> animals = new ArrayList<Animal>(); for( Class c: list_of_all_classes_available_to_my_app() ) if (c is Anamal) animals.add( new c() ); So, I want to look at all of the classes in my application's universe and when I find one that descends from Animal, I want to create a new objec...

Why do attribute references act like this with Python inheritance?

The following seems strange.. Basically, the somedata attribute seems shared between all the classes that inherited from the_base_class. class the_base_class: somedata = {} somedata['was_false_in_base'] = False class subclassthing(the_base_class): def __init__(self): print self.somedata first = subclassthing(...

DataGridView locked on a inherited UserControl

I have a UserControl with some predefined controls (groupbox,button,datagridview) on it, these controls are marked as protected and the components variable is also marked as protected. I then want to inherit from this base UserControl to another UserControl, however the DataGridView is always locked in the designer. I suspect it may ha...

Unable to save Entity Framework Inherited types.

I have implemented some table-per-type inheritance in my data model (basically have a "BaseEntity" type with all the base information for my items and a "Employer" type that inherits from the "BaseEntity" item). Everything appears to be set up correctly and when using the Entities (either via ADO.net Data Services or via Linq to Entitie...