inheritance

Inheriting from Application Styles (WPF)

I am trying to inherit application-level styles for a certain Window in my WPF application, but I'm having trouble getting it to inherit rather than simply override the existing styles. In App.xaml (under the App.Resources element) I define a style as such: <Style TargetType="Button"> <Setter Property="Padding" Value="6"/> <Set...

Objective-C Category import strange behavior

I am extending a class from a external library. Here is my code: Header file: Manager+MyCategory.h #import "Manager.h" #import "Element.h" @interface Manager (myCategory) - (Element*) elementWithTag:(NSInteger)tag; @end Implementation file: Manager+MyCategory.h file @implementation Manager (myCategory) - (Element*) elementWithT...

C++ Encapsulation Techniques

I'm trying to properly encapsulate a class A, which should only be operated on by class B. However, I want to inherit from class B. Having A friend B doesn't work -- friendship isn't inherited. What's the generally accepted way of accomplish what I want, or am I making a mistake? To give you a bit more color, class A represents a com...

Javascript prototype inheritance difference

function main() { this.one = 1; } main.prototype = { display: function() { console.log(this.one); return this; } }; function addition() { main.call(this); } addition.prototype = new main; addition.prototype.constructor = addition; addition.prototype = { add: function(x) { this.one += x; return this; } }...

How do I extend the DBProviderFactory class to accept parameters?

I am writing an ASP.NET 2.0 app. I need touse several databases, so I am using the DbProviderFactory to I can dynamically change the provider type. Although it works, I find the parameter adding a bit verbose. Because the createParameter method doesn't accept parameters itself, I end up with several lines of code like this for each param...

Need help understanding abstract classes that implement an interface

Consider the following example. I have an interface MyInterface, and then two abstract classes MyAbstractClass1 and MyAbstractClass2. MyAbstractClass1 implements MyInterface, but MyAbstractClass2 does not. Now I have three concrete classes. MyConcreteClass1 is derived from MyAbstractClass1 but does not implement MyInterface. MyConcr...

How to tell C# to look in an object's base class for a property?

I'm getting the error "T does not contain a definition for Id" below in the specified line, even though when I debug, I see that "item" does indeed have a property "Id" in its base class. How do I specify here that I want C# to look in the item's base class for Id (and why doesn't it do this automatically?)? //public abstract class Ite...

How to call an EventHandler in a parent class

Hello everyone I have added an EventHandler for the Click-event to a picturebox but on runtime this handler is never called (the debugger shows me that it is added to the control directly but when I click on the picturebox nothing happens). I assume it has something to do with my inheritance. I have a usercontrol called AbstractPage (i...

Django Model Inheritance And Foreign Keys

Basically, I have a model where I've created a superclass that many other classes share, and then each of those classes has some unique features that differ from each other. Let's say class A is the superclass, and class B, C, and D are children of that class. Both class B and class C can have multiples of class D, however I've seen tha...

prototypal inheritance (javascript)

so I'm finally understanding prototype and how to use it. I'm sure that I'm still trying to solve this as a java inheritance problem, so if there is a more prototypal way to go about this let me know. If B inherits A I want B's constructor to first execute A's constructor. This is important for setting up B's local variables. At first I...

Initializing template base-class member types in derived-class initializer lists

Here is some code outlining a problem I've been wrestling with. The final problem (as far as g++ is concerned at the moment) is that: "error: 'Foo-T' was not declared in this scope" when performing the Bar::Bar(...) constructor routine. Otherwise, the problem I'm attempting to learn my way through is one of setting base-class member type...

Why is is it not possible to pass a const set<Derived*> as const set<Base*> to a function?

Before this is marked as duplicate, I'm aware of this question, but in my case we are talking about const containers. I have 2 classes: class Base { }; class Derived : public Base { }; And a function: void register_objects(const std::set<Base*> &objects) {} I would like to invoke this function as: std::set<Derived*> objs; registe...

How do you cast an instance to a derived class?

I am trying to use a little inheritance in a Python program I am working on. I have a base class, User, which implements all of the functionality of a user. I am adding the concept of an unapproved user, which is just like a user, with the addition of a single method. The User class has some methods that return a User object. This wi...

Derived template-class access to base-class member-data

This question is a furtherance of the one asked in this thread. Using the following class definitions: template <class T> class Foo { public: Foo (const foo_arg_t foo_arg) : _foo_arg(foo_arg) { /* do something for foo */ } T Foo_T; // either a TypeA or a TypeB - TBD foo_arg_t _foo_arg; }; template <...

Calling base Text method on custom TextBox

I'm trying to create a CurrencyTextBox that inherits from TextBox. I'm seeing some really weird behavior that I just don't understand. After lots of testing, I think I can summarize as follows: In the class code, when I access base.Text (to get the textbox's text), I'm actually getting the return value of my overridden Text property. ...

Are Method Attributes Inherited in C#?

Hi, Are attributes applied to an abstract method in a base class applied to the overridden versions in the child classes? I hope the question is clear enough without an example. ...

How to override member of base class after inheritance in C++

Hello all i have this : class A { public : A(int i ) : m_S(i) { m_Pa = new Foo(*this) ; } private : int m_S ; Foo* m_Pa; } and derived class class B : public A { public : B() : A (242) { // here i like to override the A class m_Pa member but...

How to override methods in Coldfusion (adding and changing arguments etc.)?

I have two almost identical Beans. Bean "Item" contains a unique identifier (primary key), a name and an array that contains structs with data for different Users that are related to the "Item". Bean "User" contains a unique identifier (primary key), a firstname, a lastname and an array that contains structs with data of different Item...

How to hide (remove) a base class's methods in C#?

The essence of the problem is, given a class hierarchy like this: class A { protected void MethodToExpose() {} protected void MethodToHide(object param) {} } class B : A { new private void MethodToHide(object param) {} protected void NewMethodInB() {} } class C : B { public void DoSomething() ...

How would you inherit from and override the django model classes to create a listOfStringsField?

I want to create a new type of field for django models that is basically a ListOfStrings. So in your model code you would have the following: models.py: from django.db import models class ListOfStringsField(???): ??? class myDjangoModelClass(): myName = models.CharField(max_length=64) myFriends = ListOfStringsField() # ...