base-class

Java: Newbie-ish inheritance question...

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...

Is it possible to assign a base class object to a derived class reference with an explicit typecast in C#?.

Is it possible to assign a base class object to a derived class reference with an explicit typecast in C#?. I have tried it and it creates a run-time error. ...

Raise Base Class Events in Derived Classes C#

I have a base class DockedToolWindow : Form, and many classes that derive from DockedToolWindow. I have a container class that holds and assigns events to DockedToolWindow objects, however I want to invoke the events from the child class. I actually have a question about how to implement what this MSDN site is telling me to do. This sec...

C# Class naming convention: Is it BaseClass or ClassBase or AbstractClass

What is the recomemded approach to naming base classes? Will it be prefixing the type name with a "Base" or "Abstract" or whould we just suffix it with "Base"! consider the following: type: ViewModel e.g. MainViewModel, ReportViewModel base class: BaseViewModel or ViewModelBase or AbstractViewModel Also consider: type: Product e.g. ...

Which sorting algorithm is used in stl and .net base library default search?

I am now working on an imprived version of merge sort. I implemented it with C++ and C#. Then compared them with the stl sort and array.sort() algorithm respectively. In C++ I have got an equal (sometimes better) result. But in C#, I had to use unsafe code for using pointers. Here the performence is not that much comparable with default ...

Entity Base Class Library

Is there as base class library out there with entities like customer, address, order etc? ...

Access base class fn with same signature from derived class object

Hi, Is it possible to access a base class function which has the same signature as that of a derived class function using a derived class object?. here's a sample of what I'm stating below.. class base1 { public: void test() {cout<<"base1"<<endl;}; }; class der1 : public base1 { public: void test() {cout<<"der1"<<endl;...

Extending the Template Controller in Kohana

I'm having a bit of confusion in attempting to retroactively create a new base controller for my project. If I'm not mistaken, all I need to do is create a file in application/libraries called MY_baseController.php containing the following: class baseController extends Template_Controller { public function __construct() { parent...

Using base objects as parameters in a generic function

Hi I'm trying to implement a helper method using generics (C# / 3.5) I've a nice structure of classes, with base classes like so: public class SomeNiceObject : ObjectBase { public string Field1{ get; set; } } public class CollectionBase<ObjectBase>() { public bool ReadAllFromDatabase(); } public class SomeNiceObjectCollection : C...

Iterate C++ list<derived> as base class

What I want to do is this: class Ba { } class Da : public Ba {} class Db : public Ba {} class Bb // abstract base class that must not be a template. { void Process() { list<Ba*>::iterator pos; // I known the derived class will also derive // from list<Dx*> where Dx derives from Ba for(pos = this-...

.NET: Unable to cast object to interface it implements

I have a class (TabControlH60) that both inherits from a base class (UserControl) and implements an interface (IFrameworkClient). I instantiate the object using the .NET Activator class. With the returned instance, I can cast to the UserControl base class, but not to the interface. The exception I get is below the code snipet. How do I c...

C# - Hiding all methods of the UserControl class from a derived one

Hi, I have a custom user control. Normally it inherites the UserControl class. But by this way it inherites all the public methods and properties of UserControl. But I want to hide all these and implement my own few methods and properties. Say that I have a custom control named CustomControl. public class CustomControl : UserControl ...

Class Identifier used inside the class declaration. Is it a good practice?

While reviewing one of our C++ class through coverity, it showed an error message on a particular class. The class is as follows: class InputRecord { /* Construtor */ ... InputRecord::RejectRecord(); ... /* Destructor */ } What is the significance of using an identifier inside the class? Is it a good practice to fo...

C# protected members accessed via base class variable

Hello. It may seems rather newbie question, but can you explain why method Der.B() cannot access protected Foo via Base class variable? This looks weird to me: public class Base { protected int Foo; } public class Der : Base { private void B(Base b) { Foo = b.Foo; } // Error: Cannot access protected member private void D(D...

How to hide an inherited property in a class without modifying the inherited class (base class)?

Hello, If i have the following code example: public class ClassBass { public int ID { get; set; } public string Name { get; set; } } public class ClassA : ClassBass { public int JustNumber { get; set; } public ClassA() { this.ID = 0; this.Name = string.Empty; this.JustNumber = string.Empty;...

Force derived class to call base function

If I derive a class from another one and overwrite a function, I can call the base function by calling Base::myFunction() inside the implementation of myFunc in the derived class. However- is there a way to define in my Base class that the base function is called in any case, also without having it called explicitly in the overwritten f...

Is there a base object for a c# enum?

I know that you can't use inheritance with enums, so in my base class I want to define that the classes that implement it must return an enum of some type for a property. Ideally, this would be like: public abstract BaseEnum MyEnum { get; set; } Then all the implementers would have to return some form of enum. But obviously BaseEnum ...

Guarantees on address of baseclass in C++?

In C struct's, I'm guaranteed that: struct Foo { ... }; struct Bar { Foo foo; ... } Bar bar; assert(&bar == &(bar.foo)); Now, in C++, if I have: class Foo { ... }; class Bar: public Foo, public Other crap ... { ... } Bar bar; assert(&bar == (Foo*) (&bar)); // is this guaranteed? If so, can you give me a reference (like "The ...

supplying dependency through base class

I have a list of Parts and some of them need a pointer to an Engine, lets call them EngineParts. What I want is to find these EngineParts using RTTI and then give them the Engine. The problem is how to design the EnginePart. I have two options here, described below, and I don't know which one to choose. Option 1 is faster because it doe...

Visual Studio load design form

Does anyone came across a problem when you have a Class that inherits from Forms and then have all the forms inherit from Class, and then tried to load the form in design mode in visual studio? Does it loads correctly, because on mine it shows "Illegal characters in path.". I ran the visual studio in debug mode and found that it is try t...