inheritance

How can Inheritance be modelled using C?

Is it possible to model inheritance using C? How? Sample code will help. Edit: I am looking to inherit both data and methods. Containership alone will not help. Substitutability - using any derived class object where a base class object works - is what I need. ...

Entity Framework: Inheritance, change object type

Let's say, I have 2 classes in the model: User (mapped to USERS table) and PrivilegedUser (inherits User, additional info is stored in PRIVILEGEDUSERS table). Now, I have a row in USERS (and instance of User) and need to convert that user to PrivilegedUser (i.e. to create a record in PRIVILEGEDUSERS with the same Id). Is there a way to ...

How do you declare inheritance from a more than one entity (a class and one or more interfaces) in VB.NET?

I can't get a handle on the syntax. Can anyone give me a simple demo? ...

C# interface static method call with generics

Is there a simple way to implement this, and if possible without instanciating an object : interface I { static string GetClassName(); } public class Helper { static void PrintClassName<T>() where T : I { Console.WriteLine(T.GetClassName()); } } ...

Fluent NHibernate / NHibernate Inheritance Question

Possibly a dumb question but I have a number of entities all inheriting from a base entity. The base entity does not have a table in the database. Each entity has its own table and the table definition is exactly the same. Extremely simplified example of the code is below. public abstract class BaseEntity { public virtual string som...

Mapping a derived class with additional collection property in nhibernate

I'm trying to use the table-per-subclass (which fluent-nhibernate automaps by default) with a class structure like the following: public class Product { public virtual int Id{ get; set; } public virtual string Title{ get; set; } } public class ProductPackage : Product { public ProductPackage(){ Includes = new List<Product>...

C# inherited protected method implementing interface

I have this class/interface definitions in C# public class FooBase { ... protected bool Bar() { ... } ... } public interface IBar { bool Bar(); } Now I want to create a class Foo1 derived from FooBase implementing IBar: public class Foo1 : FooBase, IBar { } Is there some class declaration magic that the compiler ta...

Ruby: Inherit code that works with class variables

The situation: I have multiple classes that should each hold a variable with a configuration hash; a different hash for each class but the same for all instances of a class. At first, i tried like this class A def self.init config @@config = config end def config @@config end end class B < A; end class C < A; end Bu...

interfaces for templated classes

I'm working on a plugin framework, which supports multiple variants of a base plugin class CPlugin : IPlugin. I am using a boost::shared_ptr<IPlugin> for all reference to the plugins, except when a subsystem needs the plugin type's specific interface. I also need the ability to clone a plugin into another seprate object. This must return...

Catching a WM_NOTIFY message from a custom ListCtrl

My application is c++, and is a combination of MFC and ATL. The part I'm working with here is MFC. I have a custom list control class in one of my dialogs which inherits from CListCtrl. I'm trying to add a handler for the LVN_ITEMCHANGED message so I can update the rest of the dialog form, which is dependant on the contents of the list...

Using abstract class as a template type

I'm still pretty new to c++ (coming over from java). I have a stl list of type Actor. When Actor only contained "real" methods there was no problem. I now want to extend this class to several classes, and have a need to change some methods to be abstract, since they don't make sense as concrete anymore. As I expected (from the documenta...

Why can't I access the class internals of List<T> when I derive from it?

class NewList<T> : List<T> Why can't I access it's internals like T[] _items, etc? Why aren't they protected, but private? Should I use composition for this? ...

Multi-purpose Parser.

Im thinking of implementing a parser framework that would utilize a set of interfaces to make it easy to adapt to different types of data formats. I want to create structure around the way my controller object interacts with this parser and have come up with the following simple structure. I was hoping the community could provide any com...

[C#] Access member of second parent (inheritance)

Hello :) Here is my current layout: (the question is the comment) class A { int foo; } class B : A {} class C : B { void bar() { //I want to access foo base.foo; // Doesn't work base.base.foo // Doesn't work, of course } } As you can see, I cannot access members of A by using base in C. H...

C# Casting a List<ObjBase> as List<Obj>

Hi Why can I not cast a List<ObjBase> as List<Obj>? Why does the following not work: internal class ObjBase { } internal class Obj : ObjBase { } internal class ObjManager { internal List<Obj> returnStuff() { return getSomeStuff() as List<Obj>; } private List<ObjBase> getSomeStuff() { ...

Design a data model to flat file transformation... delegates or inheritance?

I have a maintenance application that has to turn enterprise data (from various databases/tables) into flat files, each in a specific format, for consumption by a legacy application. I've got data models like public class StatusCode { public String Id { get; set; } public Char Level { get; set; } public String Description { ...

Is it possible to subclass a django model used in a many2many though relation?

Hi there, I was wondering whether it was possible to subclass a model used as the intermediate model in a M2M relation - and then display it through the usual ModelInline procedure... The code will explain it better (in models.py): from django.db import models from django.contrib import admin #the many2many_through model first class...

Inheritance Issues in Objective C

I created an "SDMutableGrid" class so that I could use a grid. It's just a child of NSMutableArray that contains a number for arrays equal to the number of rows in the grid. Currently, the program quits before it really starts and it appears that it is because the methods defined for NSMutableArray somehow do not apply to SDMutableGrid...

jQuery and Plugin Namespacing and Inheritance

Hey guys. There has been a lot of activity lately on the jQuery Dev Group about prototypal inheritance and plugin namespacing, and I want to see who has the best answer for it. Group link: http://groups.google.com/group/jquery-dev/browse_thread/thread/620c6a18a16d9665 Questions: What do you guys think should be done about this and why...

Constructor inheritance; what am I not getting here?

I'm trying to understand inheritance in Javascript, but this code (tested in Firebug) doesn't work the way I'm expecting. What am I not understanding about it? var A = function(v){ this.v = v || 'foo'; } A.prototype.shout = function(){ alert(this.v); } var B = function(){}; B.prototype = new A; var test = new B('bar') test.shout()...