inheritance

Inheriting object and auto populate

Hi, When I want to extend an existing Object I create my own and use inherits clause, and works fantastic... problem is when I want to use this new Object instead of the original, the populate part is a "pain". is there any AUTO POPULATE way of doing this? Original Object: Customer My Object: CustomerWithGroup public class CustomerWi...

Member Pointer to Base Class

Hi, all. I can't undestand why the bellow code need a cast to work. Someone can explain it? class Base { }; class Derived : public Base { }; class Class { public: Derived member; }; ... Derived obj; Base *ptrObj = &obj; // ok, no cast needed Derived Class::* ptr = &Class::member; // ok Base Class::* ptr = &Class::member; // ...

How to extend/override controller actions of plugins ?

The plugin (Nimble 0.3) I am using in my grails application, includes some controllers and associated actions. I want to change (slightly) some actions behavior, and I was wondering how I can achieve that. Can I create a child controller that inherits from my plugin controller and override some of the action implementation? Or, can I c...

Static member inheritance in C#

I have a number of classes that reflect tables in a database. I would like to have a base class that has some basic functionality (say, it would have a "isDirty" flag), and a static array of strings with the column names as they appear in the database. The following code doesn't work but illustrates what I would like to do: public cla...

C# object initializer wanting to use wrong Add method

I have the following class hierarchy: public class Row : ICloneable, IComparable, IEquatable<Row>, IStringIndexable, IDictionary<string, string>, ICollection<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, string>>, System.Collections.IEnumerable { } public class SpecificRow : Row, IXmlSerializable, ...

C++ Seg fault on reference to stored base class pointer

Hi all. I'm getting some nasty segmentation faults through the g++ compiler on the following code. Any ideas on why this would happen and how to fix it would be great. #include <iostream> using namespace std; class Base { public: Base() {} virtual ~Base() {}; virtual int getNum(int) = 0; }; class Derived: public Base { public: ...

Confused about JavaScript prototypal inheritance...

In the book "JavaScript the definitive guide 5 edition", section 9.2 Prototypes and Inheritance, I find the following words: In the previous section, I showed that the new operator creates a new, empty object and then invokes a constructor function as a method of that object. This is not the complete story, however. After c...

How to provide a default implementation for LINQ to SQL's OnValidate method?

I'm trying to implement a validation framework in a base class for LINQ to SQL entities. The problem I'm having is getting the OnValidate event to fire properly. The reason is that OnValidate is marked as partial so I can't provide a default implementation in the base class; it gets hidden by a new method declared by the LINQ to SQL cl...

Prevent class inheritance in C++

Recently one of my friend asked me how to prevent class inheritance in C++. He wanted the compilation to fail. I was thinking about it and found 3 answers. Not sure which is the best one. 1) Private Constructor(s) class CBase { public: static CBase* CreateInstance() { CBase* b1 = new CBase(); return b1; } private: CBase(...

QMap inheritance with QMapIterator

Hi, I made a personnal class which inherits QMap: class CfgMgr : public QMap<QString, CfgSet*> {...} I'm trying to iterate over all its elements like that: CfgMgr* m_pDefaults = new CfgMgr; // .../... QMapIterator<QString, CfgSet*> ics(*m_pDefaults); while (ics.hasNext()) { // doing my stuff } And I get the compile error: ...

Castle DynamicProxy v1 exception when proxy-ing methods with parameters?

I'm having problems proxying metods with parameters using Castle DynamicProxy v1.1.5.0. - I get the exception "Index was outside the bounds of the array." If I only use methods with no parameters, OR DynamicProxy v2, everything works ok. Unfortunately, I'm having trouble convincing the leads on my project to add a dependency to v2 (we'...

how to make pre-set public property to private while creating a custom control

I am creating a custom MaskedTextBox for Date only. Now i want to hide Mask property of MaskedTextBox from its users. EDIT: public class CustomDateMask:System.Windows.Forms.MaskedTextBox { public new string Mask { get; private set; } public CustomDateMask() { ...

Can you specialize inherited Java annotations

I have an abstract superclass that has JPA annotations on it mapping some of its fields. The class itself has the @MappedSuperclass annotation. Can I specialize/add or change just one element of an inherited annotation without re-specifying the entire annotation? ...

new static fields and hiding the public inherited members

Curious situation: public class MyTextBox : TextBox { // I want use the same height for all MyTextBoxes public new static int Height; } public Form1() { InitializeComponent(); MyTextBox mtb1 = new MyTextBox(); MyTextBox mtb2 = new MyTextBox(); mtb1.Multiline = true; m...

How to get a reference to the current class from class body?

I want to keep a dictionary of (all, non-immediate included) subclasses in a base class, so that I can instantiate them from a string. I'm doing this because the CLSID is sent through a web form, so I want to restrict the choices to the ones set from the subclasses. (I don't want to eval()/globals() the classname). class BaseClass(obje...

Iterator for custom container with derived classes

I've a custom container which is implemented in two different ways, but with a single interface. some thing like this. class Vector { virtual Iterator begin() = 0; virtual Iterator end () = 0 ; ... // some more functions. } ; class VectorImplA : public Vector { Iterator begin() { return m_...

Prototypal inheritance in PHP (like in JavaScript)

Is it possible to employ some kind of prototypal inheritance in PHP like it is implemented in JavaScript? This question came to my mind just out of curiosity, not that I have to implement such thing and go against classical inheritance. It just feels like a interesting area to explore. Are there prebuild functions to combine classical ...

Which would be the best design pattern in Java for this problem?

I have a class CommonTableModel that has several instance methods and each operate on the two instance variables columnNames data Now, I have six tables, each has diff. column names but should have all the instance methods of the CommonTableModel class. So to pass an instance of the CommonTableModel to a JTable instance, I should fir...

Best way to add annotations to inherited methods

I have a number of abstract superclasses from which my concrete class inherit various methods. Some of these methods need to have JPA or JAXB annotations placed on them in the concrete class. Currently I do this via the following: @MyLocalAnnotations @Override public method inheritedMethodHere (yadda yadda) { super.inheritedMethod...

Maven 2.2.1 project inheritance: necessary to use packaging 'pom' even without the use of project aggregation (multimodule)?

I want to inherit the dependencies of a (parent) pom.xml in a child project i.e. use Project Inheritance. It seems it is necessary to change the default packaging type from 'jar' to 'pom' in this case. But doesn't tell the Maven2 documentation that the packaging type 'pom' is necessary for Project Aggregation i.e. multimodule projects w...