inheritance

Is there any way to inherit a class without constructors in .NET?

I'm currently trying to modify some HttpWebRequest functions, but I can't do it through inheritance because HttpWebRequest has no public constructors (besides the deserialization constructor). Is there a workaround to do this? My objective is to code something like the example below, but this class objects must inherit the HttpWebReques...

"Dynamic" Casting in Java

Hullo all, Wondering if there are any Java hackers who can clue me in at to why the following doesn't work: public class Parent { public Parent copy() { Parent aCopy = new Parent(); ... return aCopy; } } public class ChildN extends Parent { ... } public class Driver { public static void main(Stri...

Convention for prototype inheritance in JavaScript

I see a lot of code like this: function Base() {} function Sub() {} Sub.prototype = new Base(); However, if you do: s = new Sub(); print(s.constructor == Sub); This is false. This seems confusing to me, since s's constructor is, indeed, Sub. Is it conventional/better to do this? function Base() {} function Sub() {} Sub.prototype =...

Function with same name but different signature in derived class

I have a function with the same name, but with different signature in a base and derived classes. When I am trying to use the base class's function in another class that inherits from the derived, I receive an error. See the following code: class A { public: void foo(string s){}; }; class B : public A { public: int foo(...

How to map a deeper hierarchy in nhibernate

I have this object graph, I want to map: abstract Account (username, password, ...) abstract Customer (shoppingcart, orders, roles) IndividualCustomer (user data) CorporateCustomer (different user data, company data) Administrator (adminroles) How can this be mapped against one table? (I know how to do this with an entity hierarc...

override but don't call

How do you declare a method in C# that should be overridden (or overridable) by a dereived class - possibly even outside your assembly - but that should be callable only from within the actual class? (i.e. like a private virtual function in C++) [edit] private virtual is exactly what I intend: "Here's a way to modify my behavior, but y...

Modelling inheritance in a database.

Hi Everyone, For a database assignment I have to model a system for a school. Part of the requirements is to model information for staff, students and parents. In the UML class diagram I have modelled this as those three classes being subtypes of a person type. This is because they will all require information on, among other things...

Abstract classes and methods in Java, Inheritance

Hello, I have class B, which inherits from class A. The superclass A is abstract, containing one abstract method. I don't want to implement the abstract method in class B, therefore I need to declare class B as abstract as well. Declaring class B abstract, two things are working for me (the programs compile and run correctly): 1.) I do...

using constructor from the super class

Hello, Java does not allow multiple inheritance, meaning that a class cannot inherit from two classes, which does not have anything in common, meaning that they are not on the same inheritance path. However, a class can inherit from more classes, if these classes are super classes of the direct super class of the class. But the class in...

How do I inherit from multiple extending generic interfaces?

I have a few classes such that: public class XMLStatusMessage extends XMLMessage {} public abstract class XMLMessage implements IMessage {} public interface IMessageListener { public void onMessage( IMessage message ); } public interface XMLMessageListener <T extends XMLMessage> extends IMessageListener { public void onMe...

virtual inheritance

What is the meaning of "virtual" inheritance? I saw the following code, and I don't understand what is the meaning of the word "virtual" in the following context: class A {}; class B : public virtual A; Thanks! ...

How to return subtype in overridden method of subclass in C#?

I have a subclass with an over-ridden method that I know always returns a particular subtype of the return type declared in the base class. If I write the code this way, it won't compile. Since that probably doesn't make sense, let me give a code example: class BaseReturnType { } class DerivedReturnType : BaseReturnType { } abstract ...

Inherited Public Properties not showing up in Intellisense

I have inherited a class in vb.net and when I create the object, I am only seeing one of the inherited public properties in intellisense. Any solution to this problem? print("Public Class CompanyMailMessage Inherits MailMessage Private AdobeDisclaimer As String = "You will need Adobe Acrobat to read this file. If it is not ins...

Providing Inherited Static Properties (conceptually)

I have a C# base class that I was to associate information with on a per-type (rather than per-instance) basis. Essentially I want all child classes to present an Icon and a FriendlyName that represents the type. I'd like to not have to create a type instance to get this information and I want to require that all child classes provide ...

MVC View Inheritance

For Example: Let's say that I want to return a view that displays a list of cars and also show a section of dealers in your area. These are two disjointed pieces of data. My view inherits a list of cars like the following: public partial class CarLot : ViewPage<List<Cars>> { } Now from the controller I can return the view like the ...

Why are constructors not inherited?

I'm guessing there's something really basic about C# inheritance that I don't understand. Would someone please enlighten me? ...

Overriding a super class' instance variables

Why we are not able to override a instance variable of a super class in subclass? ...

internal constructors in a C# library

I'm writing a data access library in C#, the structure of my data model classes are as follows (within the DataAccess assembly): public abstract class DataModel {...} (protected constructor) public abstract class DataClass {...} (protected constructor) public abstract class DataField {...} (protected constructor) public class IntegerFie...

Database Inheritance Select

For my university assignment I have to design some basic managment system for sicknesses and all for a school. I have decided to model some basic inheritance in the form of Person --> Student Person --> Staff Person --> Guardian Person (PersonID, FirstName, LastName) Student (StudentID (Which references the PersonID), ... ) The re...

Multiple inheritence in C++ leading to difficulty overriding common functionality

In a C++ physics simulation, I have a class called Circle, and Square. These are Shapes, and have a method called push(), which applies force to it. There is then a special case of Circle, call it SpecialCircle, in which push() should exhibit slightly different properties. But in fact, there is also SpecialSquare() which should exhibit...