inheritance

Can web forms and generic handlers (ashx files) share a common ancestor class (or base page)?

If one has an ASP.net web site whose web forms all inherit from a common base page--which checks things like authentication and redirects when a session has expired, etc--is there a way to use this base class in a ashx handler? I started going down that road by inheriting the base page class in the handler and realized this might not be ...

In Flex, is there a way to have a common base implementation?

I have following class hierarchy interface IBaseModel interface IChildModel_A extends IBaseModel interface IChildModel_B extends IBaseModel class BaseModel implements IBaseModel class ChildModel_A extends BaseModel implements IChildModel_A class ChildModel_B extends BaseModel implements IChildModel_B I am trying to write unit tests f...

C++ new operator inheritance and inline data structures

I have a (C++) system that has many classes that have variable storage (memory) requirements. In most of these cases, the size of the required storage is known at the creation of the object, and is fixed for the lifetime of the object. I use this, for instance, to create a "String" object that has a count field, followed directly by th...

What's wrong with this example of Java property inheritance?

Inheritance.java public class InheritanceExample { static public void main(String[] args){ Cat c = new Cat(); System.out.println(c.speak()); Dog d = new Dog(); System.out.println(d.speak()); } } Animal.java public class Animal { protected String sound; public String speak(){ return sound; } } Cat.java...

Type-ing quesion

Hey everyone, I have a few tables in my database and they all contain a different inherited type of a DataRow. In addition I have a class that is supposed to handle some things in my DataGrid (My database Tables are connected to DataGrids). In order to do that, one of the methods in this DataGrid handler has to cast the rows to the exa...

Python: How to distinguish between inherited methods

Newbie Python question. I have a class that inherits from several classes, and some of the specialization classes override some methods from the base class. In certain cases, I want to call the unspecialized method. Is this possible? If so, what's the syntax? class Base(object): def Foo(self): print "Base.Foo" def B...

Trouble with inheritance of operator= in C++

I'm having trouble with the inheritance of operator=. Why doesn't this code work, and what is the best way to fix it? #include <iostream> class A { public: A & operator=(const A & a) { x = a.x; return *this; } bool operator==(const A & a) { return x == a.x; } virtual int get() = 0; ...

Partially Overriding a Virtual Auto-Property in a Child Class

Time for a theoretical question I just ran across. The following code is valid and compiles: public class Parent { public virtual object TestProperty { get; set; } } public class Child : Parent { private string _testValue = "Hello World!"; public override object TestProperty { get { return _testValue; } } ...

Can I create a single class which can be the parent for every type of Activity?

I wish to have a single class which all of my Activity classes extend. I have ListActivities, Activities, MapActivities, TabActivities, etc in my App. I have many of these different activities in my app, ~12 activities. I want each of them to have the methods which are in the parent class. Right now, i have created 4 parent activity ...

Multiple superclasses in Objective-C?

Can I inherit from multiple classes in Objective-C? (If yes, how so?) ...

Common tasks in Activities methods - how to organize them?

I have some common actions fired in onPause() and onResume() methods. (Like registering and unregistering BroadcatsReceivers) Now I put them in abstract classes and extend Activity classes. After creating some abstract classes with common actions I end up with situation when I can't extend Activity because of Java's lack of multiple in...

Template method in javascript

Hi all, I want, in javascript, to implement the template method pattern. I have a PropertyDecorator with some subclasses: OpenButtonDecorator, SeeButtonDecorator and so on. I want to have in Property decorator the next function: var build = function(){ decorate(); //Abstract in PropertyDecorator, defined in subclasses return le....

How to check if an interface extends another in C#?

The Type.IsSubclassOf method only works with two concrete types, e.g. public class A {} public class B : A {} typeof(B).IsSubclassOf(typeof(A)) // returns true Is there a way to find out if an interface extends another? e.g. public interface IA {} public interface IB : IA {} The only thing I can think of is to use GetInterfaces on ...

Ruby: kind_of? vs. instance_of? vs. is_a?

What is the difference? When should I use which? Why are there so many of them? ...

C# ASP.NET MasterPage nested inheritance is evil

I have a solution with quite a few different MasterPages / BasePages which all inherit from somewhere else. My problem is that I have a virtual string in BaseMaster, which is overridden by BaseManagement, but when I try to access this string I always get the base value The point of inheriting masters and pages is obviously to avoid havi...

Entity framework inheritance

I'll try to explain the problem I'm currently facing as simply as possible. The project I'm currently working on is required to analyze some financial data. For convenience, this data should be stored in a database, so I'm tasked with creating a database model. While the database wasn't required up until now, the application itself has b...

Java Generic Object Passing

Hello Everybody! I'm playing around on GAE (I'm using Objectify) and wanted to make something like a generic method, but aint sure how to do it (and as far as my understandig goes, generics wouldn't be a solution for me). This is my setup: public abstract class Cloud{ Key<Cloud> parent; public Cloud(Key<Cloud> parent,...){ ...

What is the code : base()

What is the purpose of base() in the following code? class mytextbox : TextBox { public mytextbox() : base() { this.Text = "stack"; } } ...

.net: Please help me understand why this is completely legal in .net?

Suppose we have declared these two classes: public class Animal { //..... } public class Dog : Animal { //..... } Well, my question is: why below line of code is valid? Animal animal = new Dog(); EDIT: In e-book, "Professional C# 2008", there is a paragraph that says: It's always safe to store a derived type within a b...

private inheritance, friends, and exception-handling

Hi. When class A privately inherits from class B it means that B is a private base class subobject of A. But not for friends, for friends it is a public sububject. And when there are multiple catch handlers the first one that matches (that is, if the exception type can be implicitly converted to the handler's parameter type) is called. S...