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 ...
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...
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...
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...
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...
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...
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; ...
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; }
}
...
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 ...
Can I inherit from multiple classes in Objective-C? (If yes, how so?)
...
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...
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....
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 ...
What is the difference? When should I use which? Why are there so many of them?
...
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...
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...
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 purpose of base() in the following code?
class mytextbox : TextBox
{
public mytextbox() : base()
{
this.Text = "stack";
}
}
...
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...
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...