inheritance

Composing objects of a class you inherit from?

I have a class Parameter, the purpose of which is to represent the possible values a certain parameter could hold (implements two key methods, GetNumValues() and GetValue(int index)). Often one logical parameter (parameter values are bit flags) is best represented by 2 or more instances of the Parameter class (i.e. a Parameter that can ...

Are virtual destructors inherited?

If I have a base class with a virtual destructor. Has a derived class to declare a virtual destructor too? class base { public: virtual ~base () {} }; class derived : base { public: virtual ~derived () {} // 1) ~derived () {} // 2) }; Concrete questions: Is 1) and 2) the same? Is 2) automatically virtual because of its...

Change classes in Java

Hello Folks I have a class ImageA, and a class ImageB. The both classes represents an image in my app, but each one in a different way. Even being different, their constructors are equal, and both have the method compare. So, what I done was creating a class Image, and ImageA and ImageB are subClasses of Image. public abstract class I...

Trying to inherit three base classes and can't

Hi. I have a few questions related to the design of my User class but they are different enough that I think they should be independent questions. So, the first is related to inheritance of base classes. I am currently inheriting two classes, ProfileBase and ISessionMgrEntry as such: public class User : ProfileBase, ISessionMgrEntr...

how to create a factory that dynamicly extend a class so its type changes but it inherents parent methods.

What I would like to do is have a static factory function that you give it a series of attributes and it returns an object that is of a previously undeclared class that extends a known class. Basically: <?php class foo{ public $a; function increment($b = 1){ $this->a += $b; } } function factory($name, $a){ //returns an ob...

Inheritance in CSS? Possible to do this without copy and paste?

Hi, I'm trying to follow the nifty tutorial at http://www.kriesi.at/archives/create-a-multilevel-dropdown-menu-with-css-and-improve-it-via-jquery and well, it hit me that I'm trying to use jquery's CSS for theming.. So if I have a menu like <ul id="AVPNav"> <li><a href="#">Agfdts</a> <ul> <li><a href="~/Apfgsdfg.aspx?node=ad...

When overriding a method from a parent class; what does NotImplementedException() mean?

Here's an example: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SharpLibrary_MediaManager { public class Picture:BaseFile { public override void GetFileInformation() { throw new NotImplementedException(); } public override void GetTh...

Why am I getting this error when overriding an inherited method?

Here's my parent class: public abstract class BaseFile { public string Name { get; set; } public string FileType { get; set; } public long Size { get; set; } public DateTime CreationDate { get; set; } public DateTime ModificationDate { get; set; } public abstract void GetFileInfor...

jUnit ignore @Test methods from base class

Let's say I have a test class called testFixtureA with serveral methods testA, testB, testC, etc, each with @Test annotation. Let's now say I subclass testFixtureA into class called testFixtureAB and I don't overwrite anything. testFixtureAB is empty as for now. When I run tests from testFixtureAB, methods testA, testB and testC are ...

Problem in Inheritance in Java.

I have 5 different tables in a database. I have written an abstract "Converter.java" class that take out data from the database and convert it into a "tree.xml" file. Tree.xml <?xml version="1.0" standalone="no"?> <tree> <declarations> <attributeDec1 name="name" type="String"/> </declarations> <branch> <attribut...

Another problem in inheritance of Java?

I have a Parent.java class and 4 child classes as Child1.java, Child2.java and so on. There are two methods m1() m2() and one field f1 Field f1 has different values based on the child class. Method m1 has the common implementation so I have put it in Parent.java class. It also refers method m2. Method m2 has common implem...

WinForms UserControl inheritance in .Net Compact Framework

The full .Net framework has an inherited UserControl but this option isn't offered by Visual Studio when creating a new control in a Compact Framework project. Manually changing the ancestor class of a user control to another user control results in an exception being thrown by the designer when subsequently trying to open it. Anyone k...

Nhibernate Common columns in base class

I want to design following scenario Base class (Id, Name, order, Value) 3 Derived classes derive1, derive2, derive3 inheriting properties from base There is no table for base class. And 1 table for each derived class. 3 tables have same columns. How can I create mapping file ignoring base class? Do I need to create 1 mapping file fo...

JavaScript nested inheritance

I've been trying to get my head around JavaScript inheritance. Confusingly, there seem to be many different approaches - Crockford presents quite a few of those, but can't quite grok his prose (or perhaps just fail to relate it to my particular scenario). Here's an example of what I have so far: // base class var Item = function( type...

Retrieving subclass type in base class?

I am attempting to use the Microsoft enterprise Validation methods to perform validation in my entities. In my base class I have the following method: public class BaseEntity { public bool IsValid() { return Validate().IsValid; } public ValidationResults Validate() { return Validation.Validate<this.GetType()>(this)...

Can you get merged attributes for a class in C#?

Say I have the following set of classes, is it possible for the attributes of DerivedClass to be merged? Currently if I use the GetType().GetCustomAttributes()method passing in true for inheritance it takes the highest attributes in the inheritance structure. i.e. [Another("Bob")] and [My(16)] Is it possible for the attributes to be me...

How to avoid parallel inheritance hierarchies among GUI controls and domain objects.

I am developing a Windows Forms application in C#. I am using the MVP design pattern. In the GUI the user can manipulate printer objects, and there needs to be custom controls that represent the printer objects to the user. There is a class hierarchy that represents the printers. At the base there is an abstract Printer class. Then ...

What should the iterator type be in this C++ template?

While working on some graphics code a while back, I wrote Rect and Region classes using ints as the underlying coordinate holder, and that worked fine. The Region was implemented as a simple class extension to an STL list, and just contains a list of Rects. Now I also need the same kinds of classes using doubles as the underlying coordi...

Is there any way to inherit from TriggerAction class?

I am not interested in animations and I am trying to make simple setter action to be set without key frames. I wanted to inherit TriggerAction; make properties that set the new value on target, any additional optional properties so I can use: <EventTrigger SourceName="btn" RoutedEvent="Click"> <BooleanActionTrigger TargetName="cb" ...

Django templates - can I set a variable to be used in a parent template?

I have a parent template that contains a generic navigation menu. I want to be able to add class="selected" to the appropriate menu option. I want to be able to set a variable in a child template, for example: {% set menu = "products" %} and do: {%ifequal menu "products" %}class="selected"{% endifequal %} I don't want to set a val...