inheritance

Looking for a better way than virtual inheritance in C++

OK, I have a somewhat complicated system in C++. In a nutshell, I need to add a method to a third party abstract base class. The third party also provides a ton of derived classes that also need the new functionality. I'm using a library that provides a standard Shape interface, as well as some common shapes. class Shape { public: ...

Is there anyway to declare a TYPE without a Property in Oracle 10gR2

I want to create a base object that has only methods. The object would be QUEUABLE_OBJECT_TYPE and it will have an ENQUEUE method(s). The Payload of these messages (properties) would be added by subtyping this object. I get an error that makes it sound like you cannot. PLS-00589: no attributes found in object type "QUEUABLE_OBJECT_T...

Why aren't classes sealed by default?

I was just wondering, since the sealed keyword's existence indicates that it's the class author's decision as to whether other classes are allowed to inherit from it, why aren't classes sealed by default, with some keyword to mark them explicitly as extensible? I know it's somewhat different, but access modifiers work this way. With the...

Why Can A C# Class Inherit From One Interface Both Implicitly and Explicitly?

Today I happens to find that one C# class can inherit one interface both in implicit and explicit way. This surprises me. If C# works in this way, then one instance can behave differently when referenced in different way. interface IFoo { void DoSomething(); } class Foo : IFoo { #region IFoo Members public void DoSomething(...

How do you inherit from a class in a different header file?

I am having dependency troubles. I have two classes: Graphic and Image. Each one has its own .cpp and .h files. I am declaring them as the following: Graphic.h: #include "Image.h" class Image; class Graphic { ... }; `Image.h`: #include "Graphic.h" class Graphic; class Image : public Gr...

Creating a derived control

I have an abstract base class which inherits from UserControl and which is then used to derive a number of classes. The problem I have is how to elegantly ensure that the generated function InitializeComponent() is called for each layer of class. So the (abstract) base class has a number of controls on it that will be shared for all ...

LinQ ORM Data Objects and Inheritance.

I'm thinking about how to do this, but I have several different shapes of Data in my Database, Articles, NewsItems, etc. They All have something in common, they all have IDs (in the DB they're named ArticleID, NewsID etc. ) They all have a Title They all have BodyText. They all have a Status They all have a DateAdded What I'd lik...

Would syntax for composition be a useful addition to Java?

First off, I know next to nothing about language theory, and I barely know any other languages except Java, but I had an idea that I think would be cool, but I need you guys to tell me: a: why it sucks b: how language x has had that for years c: how my mind sucks d: all of the above The idea would give composition the same ease of code ...

Multiple Inheritance from two derived classes

I have an abstract base class which acts as an interface. I have two "sets" of derived classes, which implement half of the abstract class. ( one "set" defines the abstract virtual methods related to initialization, the other "set" defines those related to the actual "work". ) I then have derived classes which use multiple inheritance ...

Any sensible examples of creating inheritance without creating subtyping relations?

I've been teaching OOP and was trying to convey to my students the important difference between inheritance and the creation of a subtype relation between two types. For example, in C++, I could use private inheritance to ensure that nobody outside sees the subtyping relation. However, while I can think of a lot of situations where I wo...

C# Interface Implementation relationship is just "Can-Do" Relationship?

Today somebody told me that interface implementation in C# is just "Can-Do" relationship, not "Is-A" relationship. This conflicts with my long-time believing in LSP(Liskov Substitution Principle). I always think that all inheritance should means "Is-A" relationship. So, If interface implementation is just a "Can-Do" relationship. What ...

App crash when trying to access a subclass method after the object was initialized ( init ) using the parent initializer

Hi, I have a class that subclasses NSMutableArray. I init it using: MyClass class = [MyClass arrayWithContentsOfFile:path]; When i try to access any of my subclass methods the app crashes with this error: -[NSCFArray loadCards]: unrecognized selector sent to instance 0x454a30 * Terminating app due to uncaught exception 'NSI...

Inheritance question - retrieving data from Access database file and SQL Express

Hi, I am developing an application which will be connected to Access database at the beginning and the plan is to switch to MS SQL or SQL Express in the near future. The datatables structures are same for both types of databases and I am trying to avoid duplicating the code and trying to find the way to minimize the code. For example I...

How do I inherit subroutines in Perl with 'use base'?

How do I apply 'use base' in Perl to inherit subs from some base module? I'm used to C++ inheritance mechanics, and all the sites I googled for this caused more confusion then help. I want to do something like the following: #! /usr/bin/perl #The base class to inherit from use strict; use warnings; package 'TestBase'; #--------------...

Exposing inherited members of a COM vb.net class

I have two vb.net class: Public MustInherit Class Class1 Private m_sProperty1 As String = "" Public Property sProperty1() As String Get Return m_sProperty1 End Get Set(ByVal value As String) m_sProperty1 = value End Set End Property End Class <ComClass("classid","inter...

Class Variables in Javascript

I'm having a bit of trouble trying to get class variables to work in javascript. I thought that I understood the prototype inheritance model, but obviously not. I assumed that since prototypes will be shared between objects then so will their variables. This is why this bit of code confuses me. What is the correct way to implement...

How do I use 'Order By' to sort on a property of an inherited type in LINQ-to-SQL?

Hi, I have a fairly standard inheritance situation in my current LINQ-to-SQL project. I have a base class called 'Party' and classes called 'Individual' and 'Organisation' which inherit from it. What I want to achieve seems (and probably is) fairly simple. I want to return a list of 'Organisations' sorted by Company Name. The problem i...

Mapping multi-Level inheritance in Hibernate

Currently I have a structure like this: A | +--B | +--C It's mapped with one table per subclass using joined tables. For historic reasons I also use a discriminator, so the current situation is as described in Section 9.1.3 of the Hibernate manual. Question: How do I extend the mapping for a structure like this: A | +--B | | | D |...

Java Instance Variable Accessibility

What is the difference in the accessibility of the following variables in Java? public class Joe { public int a; protected int b; private int b; int c; } I'm most interested in what the last one is doing. ...

Inheritance and interfaces

This is somewhat of a follow-up question to this question. Suppose I have an inheritance tree as follows: Car -> Ford -> Mustang -> MustangGT Is there a benefit to defining interfaces for each of these classes? Example: ICar -> IFord -> IMustang -> IMustangGT I can see that maybe other classes (like Chevy) would want to implement...