I have a java class which fires custom java events. The structure of the code is the following:
public class AEvent extends EventObject {
...
}
public interface AListener extends EventListener {
public void event1(AEvent event);
}
public class A {
public synchronized void addAListener(AListener l) {
..
}
public synchroni...
Working with VS.NET 2008, output type Class Library, Target Framework .NET 2.0
I've come up with a simplified scenario to ask this question.
I have a Button user control, its a simple panel with a single big button on it.
I want to create a RedButton control that extends Button, and similarly, a GreenButton.e.g. Class RedButton : Butt...
I need to represent inheritance like Person/Student. How do you do that in LInqToSql?
...
In C++, I can't think of a case in which I would like to inherit private/protected from a
base class:
class Base;
class Derived1 : private Base;
class Derived2 : protected Base;
Is it really useful?
...
I've trying to achieve something like this:
class Base
{
public:
Base(string S)
{
...
};
}
class Derived: Base
{
public:
int foo;
string bar()
{
return stringof(foo); // actually, something more complex
};
Derived(int f) : foo(f), Base(bar())
{
};
}
Now, this doesn't work as I want, because bar() is ca...
I saw in the apache camel source code that
public class DefaultCamelContext extends ServiceSupport implements CamelContext, Service
My question is why this definition since
public interface CamelContext extends Service
and also
public abstract class ServiceSupport implements Service
Shouldn't it be just
public class DefaultCam...
I'm not really sure how to title this question but basically I have an interface like this:
public interface IFoo
{
string ToCMD();
}
a couple of absract classes which implement IFoo like:
public abstract class Foo : IFoo
{
public abstract string ToCMD();
}
public abstract class Bar : IFoo
{
public abstract string ToCMD()...
I have this in my xsd:
<xsd:simpleType name="line_action">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="add"/>
<xsd:enumeration value="delete"/>
<xsd:enumeration value="remove"/>
<xsd:enumeration value="suspend"/>
<xsd:enumeration value="restore"/>
<xsd:e...
I wanted to create my own Python exception class, like this:
class MyException(BaseException):
def __init__(self, errno, address):
if errno == 10048:
mess = str(address) + ' is already in use'
else:
mess = 'Unable to open ' + str(address)
BaseException.__init__(mess)
but when the pro...
I know that having diamond inheritance is considered bad practice. However, I have 2 cases in which I feel that diamond inheritance could fit very nicely. I want to ask, would you recommend me to use diamond inheritance in these cases, or is there another design that could be better.
Case 1: I want to create classes that represent diffe...
I'm trying to make a database and so far, I've been using strings to store my entries from a text file into an array, but this just isn't working out. Thus, I began thinking of a new way of doing it.
What I want to do:
Lets say I have a text file with the following database...
John Smith 00001 jsmith@email pw1
Rob Deniro 00002 ...
#include<iostream>
using namespace std;
class A
{
int a;
int b;
public:
void eat()
{
cout<<"A::eat()"<<endl;
}
};
class B: public A
{
public:
void eat()
{
cout<<"B::eat()"<<endl;
}
};
class C: public A
{
public:
void eat()
{
cout<<"C::eat()"<<endl;
}
};
class D: pub...
I have read that private variables in a base class are technically inherited by child classes, but are not accessible.
If this is correct, why do we say they are inherited when presumably they can only be accessed by reflection?
...
This is a purely theoretical question.
Given three simple classes:
class Base {
}
class Sub extends Base {
}
class SubSub extends Sub {
}
And a function meant to operate on these classes:
public static void doSomething(Base b) {
System.out.println("BASE CALLED");
}
public static void doSomething(Sub b) {
System.out.println...
Say I have three classes:
class X{};
class Y{};
class Both : public X, public Y {};
I mean to say I have two classes, and then a third class which extends both (multiple-inheritance).
Now say I have a function defined in another class:
void doIt(X *arg) { }
void doIt(Y *arg) { }
and I call this function with an instance of both:
...
Hi, I've been watching Douglas Crockford's talks at YUI Theater and I have a question about javascript inheritance...
Douglas gives this example to show that "Hoozit" inherits from "Gizmo":
function Hoozit(id) {
this.id = id;
}
Hoozit.prototype = new Gizmo();
Hoozit.prototype.test = function (id) {
return this.id === id;
};
M...
I have a base class with a virtual method, and multiple subclasses that override that method.
When I encounter one of those subclasses, I would like to call the overridden method, but without knowledge of the subclass. I can think of ugly ways to do this (check a value and cast it), but it seems like there should be an in-language way t...
Hi, I'been doing some inheritance in js in order to understand it better, and I found something that confuses me.
I know that when you call an 'constructor function' with the new keyword, you get a new object with a reference to that function's prototype.
I also know that in order to make prototypal inheritance you must replace the pro...
Hello,
I have an object tree that looks something like
Ball
/ \
LegalBall IllegalBall
And I have 2 methods:
class o {
AddBall(LegalBall l)
AddBall(IllegalBall i)
}
in another class I'd like to do the following:
o.AddBall(myBall);
where myBall is of type Ball.
And get it to call the correct method de...
How would the following scenario best be implemented:
There is a standardized user interface for an application in version 1.0, e.g. an order form. This application gets customized to fit the needs of different customers. This could be an extra field "desired delivery time" for customer A, the omittance of the field "phone number" for c...