Suppose I have the following declaration:
class Over1
{
protected:
class Under1
{
};
};
I know that I could do the following:
class Over2 : public Over1
{
protected:
class Under2 : public Under1
{
};
};
But is there a way to declare Under2 without Over2?
Since you would have to exte...
In java, I could do this with the 'final' keyword. I don't see 'final' in C#. Is there a substitute?
...
Before you start firing at me, I'm NOT looking to do this, but someone in another post said it was possible. How is it possible? I've never heard of inheriting from anything using reflection. But I've seen some strange things...
...
Hello,
As far as i know it is not possible to do the following in C# 2.0
public class Father
{
public virtual Father SomePropertyName
{
get
{
return this;
}
}
}
public class Child : Father
{
public override Child SomePropertyName
{
get
{
return this;...
I've got a (poorly written) base class that I want to wrap in a proxy object. The base class resembles the following:
public class BaseClass : SomeOtherBase
{
public BaseClass() {}
public BaseClass(int someValue) {}
//...more code, not important here
}
and, my proxy resembles:
public BaseClassProxy : BaseClass
{
public ...
Suppose I have a base class B, and a derived class D. I wish to have a method foo() within my base class that returns a new object of whatever type the instance is. So, for example, if I call B.foo() it returns an object of type B, while if I call D.foo() it returns an object of type D; meanwhile, the implementation resides solely in t...
I've never been so good at design because there are so many different possibilities and they all have pros and cons and I'm never sure which to go with. Anyway, here's my problem, I have a need for many different loosly related classes to have validation. However, some of these classes will need extra information to do the validation. I ...
I know how to use JSON to create objects, but there doesn't seem to be away to use JSON to create an object that is of a specific object type.
Here's an example of an Object and creating an instance of it:
Person = function() { };
Person.prototype = {
FirstName: null,
GetFirstName: function() {
return this.FirstName;
...
One of the major advantages with Javascript is said to be that it is a prototype based language.
But what does it mean that Javascript is prototype based and why is that an advantage?
...
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in calendar user control.
the code-behind file for my control looks like this:
public partial class WeeklyEventsCalendar : Calendar
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
and compiles fine.
However, when I try t...
I've been working on a project in Delphi 7 where I wanted to have forms inherit components from other forms. I was able to get this working, but came across the following issues (and I'm going to post the solutions to hopefully help others in the future):
In the .pas file of a form, I would change the form to inherit from some other fo...
I am still trying to wrap my head around design patterns and for the second time I'm coming up against the same problem that seems to be crying out for a pattern solution.
I have an accounts system with multiple account types. We have restaurant, hotel, service_provider, and consumer account types. Im sure there will be more business a...
I have come across numerous arguments against the inclusion of multiple inheritance in C#, some of which include (philosophical arguments aside):
Multiple inheritance is too complicated and often ambiguous
It is unnecessary because interfaces provide something similar
Composition is a good substitute where interfaces are inappropriate
...
Given the following inheritance tree, what would be the best way of implementing it in a way that works?
abstract class Foo<T> : IEnumerable<T>
{
public abstract Bar CreateBar();
}
class Bar<T> : Foo<T>
{
// Bar's provide a proxy interface to Foo's and limit access nicely.
// The general public shouldn't be making these tho...
I had a coworker see this the other day and I'm not quite sure why this happened. Can anyone explain it?
We have class A:
using System;
using System.Data;
public class A
{
protected DataTable _table;
public A()
{
}
}
We have class B that inherits from class A (assume there in the same namespace):
using System;
public cla...
Hallo i am currently playing around with castle projects ActiveRecord and the remoting facility.
my current problem is that i need the find a way the implement the save sub from IBaseRepository in my address class and i dont know how.
here is my current code, VS tells me on the line "implements IAddress"
that i have to implement Sub Sa...
I want to do something like this:
List<Animal> animals = new ArrayList<Animal>();
for( Class c: list_of_all_classes_available_to_my_app() )
if (c is Anamal)
animals.add( new c() );
So, I want to look at all of the classes in my application's universe and when I find one that descends from Animal, I want to create a new objec...
The following seems strange.. Basically, the somedata attribute seems shared between all the classes that inherited from the_base_class.
class the_base_class:
somedata = {}
somedata['was_false_in_base'] = False
class subclassthing(the_base_class):
def __init__(self):
print self.somedata
first = subclassthing(...
I have a UserControl with some predefined controls (groupbox,button,datagridview) on it, these controls are marked as protected and the components variable is also marked as protected.
I then want to inherit from this base UserControl to another UserControl, however the DataGridView is always locked in the designer.
I suspect it may ha...
I have implemented some table-per-type inheritance in my data model (basically have a "BaseEntity" type with all the base information for my items and a "Employer" type that inherits from the "BaseEntity" item). Everything appears to be set up correctly and when using the Entities (either via ADO.net Data Services or via Linq to Entitie...