base-class

How can I access a Masterpage property from a base class or other functions file

I'm accessing Masterpage properties from a regular ASP.NET C# page by doing the following: ((SecondMasterPage)(Page.Master)).speciallink = true; ((SecondMasterPage)(Page.Master)).specialspan = false; That works fine in a page's code-behind, but when I try to move it to a function in my base class file like this: public class MyBase...

C# - Get the implemented type from a Generic Base Class

I may of worded the title completely wrong, but basically, I have the following base class: public class ScheduleableService<T> : ServiceBase where T : IJob { var x = typeof(T); } The implementation of this is something like: public class MyScheduledService: ScheduleableService<MyScheduledJob> { //MyScheduledJob i...

ASP.NET event lifecycle for inherited user controls

Please forgive the psuedo-code, but it's a simple question: I create a user control (myControlBase : UserControl) with a textbox (id = "txtbox") in it's markup. In it's codebehind I write a method SayHello(string s){ txtbox.Text = s; }. I create another user control that extends myControlBase (myControl : myControlBase). In page_lo...

C++: Avoiding dual maintenance in inheritance hierarchies

When creating a C++ inheritance structure, you have to define member functions exactly the same in multiple places: If B is an abstract base class, and D, E, and F all inherit from B, you might have this: class B { virtual func A( ... params ) = 0; }; class D : public B { func A( ... params ); }; /* ... etc... similar implement...

[C#] invoke a new method of a sub class from base class

Hello, I've some classes like this namespace ConsoleApplication1 { class Program { static void Main(string[] args) { A a = new C(); a.method(); Console.ReadLine(); } } public class A { public virtual void method() { Console.Writ...

How to make user control partial classes aware of controls declared in the base class?

Do we have to do something special to have ASP.NET partial classes aware of controls that are declared in our user control's base classes? The partial classes keep generating declarations for controls in the base class which mean the controls in the base class get hidden and are null. ...

Concise (yet still expressive) C++ syntax to invoke base class methods

I want to specifically invoke the base class method; what's the most concise way to do this? For example: class Base { public: bool operator != (Base&); }; class Child : public Base { public: bool operator != (Child& child_) { if(Base::operator!=(child_)) // Is there a more concise syntax than this? return true; /...

Exception catching from base of the class

I have a base class, and I would like to catch all exceptions of the derived class within the base class, is this possible? You won't know what the methods are from the derived class. ...

Is a base class with shared fields and functions good design

I've got a BaseDataClass with shared fields and functions Protected Shared dbase as SqlDatabase Protected Shared dbCommand as DBCommand ... //also have a sync object used by the derived classes for Synclock'ing Protected Shared ReadOnly syncObj As Object = New Object() Protected Shared Sub Init() //initializes...

'abstract class' versus 'normal class' for a reusable library

I'm developing a reusable library and have been creating abstract classes, so the client can then extend from these. QUESTION: Is there any reason in fact I should use an abstract class here as opposed to just a normal class? Note - Have already decided I do not want to use interfaces as I want to include actual default methods in ...

Can can I reference extended methods/params without having to cast from the base class object returned

Hi, Is there away to not have a "cast" the top.First().Value() return to "Node", but rather have it automatically assume this (as opposed to NodeBase), so I then see extended attributes for the class I define in Node? That is is there a way to say: top.Nodes.First().Value.Path; as opposed to now having to go: ((Node)top.Nodes.Fir...

With this generics code why am I getting "Argument 1: cannot convert from 'ToplogyLibrary.RelationshipBase<TNode>' to 'TRelationship'"

Hi, Any see why I'm getting a "Argument 1: cannot convert from 'ToplogyLibrary.RelationshipBase' to 'TRelationship'" in the code below, in CreateRelationship() ? public class TopologyBase<TKey, TNode, TRelationship> where TNode : NodeBase<TKey>, new() where TRelationship : RelationshipBase<TKey>, new() { // Properties p...

polymorphism, inheritance in c# - base class calling overridden method?

This code doesn't work, but hopefully you'll get what I'm trying to achieve here. I've got a Money class, which I've taken from http://www.noticeablydifferent.com/CodeSamples/Money.aspx, and extended it a little to include currency conversion. The implementation for the actual conversion rate could be different in each project, so I d...

Can a grails controller extend from a base class? How to make it so grails doesn't blow up?

I wrote a base class to help build my controllers more quickly and to remove duplication. It provides some helper methods, default actions and some meta programming to make these things easier to build. One of those methods in the base class is like this: def dynamicList(Class clazz) { def model = new LinkedHashMap() model[getM...

C#: why Base class is allowed to implement an interface contract without inheriting from it?

I've stumbled upon this "feature" of C# - the base class that implements interface methods does not have to derive from it. Example: public interface IContract { void Func(); } // Note that Base does **not** derive from IContract public abstract class Base { public void Func() { Console.WriteLine("Base.Func"); ...

Interface and base class mix, the right way to implement this

I have some user controls which I want to specify properties and methods for. They inherit from a base class, because they all have properties such as "Foo" and "Bar", and the reason I used a base class is so that I dont have to manually implement all of these properties in each derived class. However, I want to have a method that is o...

compiler warning at C++ template base class

I get a compiler warning, that I don't understand in that context, when I compile the "Child.cpp" from the following code. (Don't wonder: I stripped off my class declarations to the bare minuum, so the content will not make much sense, but you will see the problem quicker). I get the warning with VS2003 and VS2008 on the highest warning ...

Multi-tier applications using L2S, WCF and Base Class

Hi all. One day I decided to build this nice multi-tier application using L2S and WCF. The simplified model is : DataBase->L2S->Wrapper(DTO)->Client Application. The communication between Client and Database is achieved by using Data Transfer Objects which contain entity objects as their properties. abstract public class BaseObject ...

C++ : Call a base class method automatically ?

Here we go, I'm trying to implement the command design pattern, but I'm stumbling accross a conceptual problem. Let's say you have a base class and a few subclasses like in the example bellow : class Command : public boost::noncopyable { virtual ResultType operator()()=0; //restores the model state as it was before command'...

Erroneous private base class inaccessible?

Compiling this code using g++ 4.2.1: struct S { }; template<typename T> struct ST { }; template<typename BaseType> class ref_count : private BaseType { }; template<typename RefCountType> class rep_base : public RefCountType { }; class wrap_rep : public rep_base<ref_count<S> > { typedef rep_base<ref_count<S> > base_type; // lin...