inheritance

virtual function redefinition hides other overloaded functions of same name from another base class

Ok, I'm using virtual functions, overloaded functions, and multiple inheritance. Of course this doesn't turn out well. The scenario: Class base1 has a virtual function that needs to be specified by its child. Class derived derives from two parents base1 and base2, and should use base2's existing functionality to define base1's virtual ...

Using LINQ to find the class that is in the bottom of the inheritance chain

Given a sequence of assemblies with classes eg. AssemblyA Customer AssemblyB Customer : AssemblyA.Customer AssemblyC Customer : AssemblyB.Customer Given the name (not taken care of namespace) Customer, can I use LINQ to query against the sequence of assemblies to find the customer at the bottom of the inheritance cha...

Hibernate Inheritance Modeling

Hi All, I'm having trouble creating a model for a couple entities that is sane in both Hibernate and the Database. Any help is appreciated. A company entity and table exists, which provides both a company name and a "company code". The company code must be unique. Company's may act as 2 different entities, clients or partners. We'd ...

inheritance problem

I've messed up something. Here is the code: #include <iostream> class connection_c { private: std::string data_; void (*saveCallBack_)(); public: connection_c(std::string &data) : data_(data) { std::cout << "ctor: " << __FUNCTION__ << ":" << data_ << std::endl;} void registerCallBack(void(*cb)()) { saveCallBack_ = c...

Unit Testing abstract classes and or interfaces

I'm trying to start using Unit Testing on my current project in Visual Studio 2010. My class structure, however, contains a number of interface and abstract class inheritance relationships. If two classes are derived from the same abstract class, or interface I'd like to be able to share the testing code between them. I'm not sure how t...

[C#] Delegate doesn't accept subclass?

My delegate doens't seem to accept a subclass, I think an example is the easiest. public class A { public A() { } } public class B : A { public B() { } } public class Program { private delegate void CallBack(A a); private static CallBack callBack = new CallBack(Test); public Main(string[] args) { ...

WPF: How to reuse controls when ObservableCollection is concrete?

I have a object that inherits from TabItem. I have a bunch of Database objects that will reuse the same code so I wanted only one TabItem class and then use DataTemplates to control how each object gets presented. Problem is that the TabItem shows a collection of Objects and ObservableCollection is concrete. I've pondered a few solutio...

How to get an Entity Framework class inherit a base class

I have several classes that inherit from an abstract base class that holds some common utility code. I want to move to EF for data access but I'd still like the objects to inherit the common code in the base class. The EF classes already inherit from EntityObject so I can't have them inherit my base class. What's the right way to handle ...

Overriding a Sub procedure in VB.NET

I have a main class that has a Sub procedure with no implementation. Any derived class should override and implement this procedure, so I used MustOverride in the base class. Now, any time this procedure is called, I need to set a specific Boolean variable to True at the beginning of the procedure and set it to False at the end. Is the...

Where() at abstract level to return new self

I have this code and I want to keep it elegant. I got stuck at this inheriting issue and I would have to mess up the code if I do. Help me keep it elegant. I don't mind making changes anywhere up and down the hierarchy; feel free to change the core. I have these abstract classes (I omitted unrelated implementation to keep the question ...

Lack of component inheritance in NHibernate - how do I get around this?

I'm trying to do almost exactly the same thing as this post: http://colinjack.blogspot.com/2008/03/nhibernate-working-around-lack-of.html but I can't get the suggested solution to work for me. Essentially I have one main class, which has a reference to an abstract class. The abstract class has several implementations. I want the comm...

Member access in Inheritance Hierarchy - C++

struct A { protected: int y; public: int z; }; struct F : A { public: using A::y; private: using A::z; }; int main() { F obj_F; obj_F.y = 9; obj_F.z = 10; } Source: http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=/com.ibm.vacpp7a.doc/language/ref/clrc14cplr135.htm In the above code obj_F.z = 10;...

Assign derived class to base class

Is it safe to do the following or is it undefined behaviour: class Base { private: int a; }; class Derived : public Base { private: int b; }; Base x; Derived y; x = y; // safe? Do the extra bits in derived classes just get sliced off? ...

What is the correct way to implement the comparison for a base class?

I have a base class class Animal with pure virtual functions, and a set of derived classes class Monkey : public Animal class Snake : public Animal I want to implement a comparison operation so that, if I encounter two pointers to Animals in my code Animal* animal1 Animal* animal2 I can compare them to each other. The compar...

how to extend javascript classes

Why Child class doesn't have echo() method? Parent = function(){ this.name = 'abc'; } Parent.prototype.echo = function(){ alert(this.name); } Child = function(){ $.extend(this, Parent); } var x = new Child(); x.echo(); What should I do to inherit from parent class in Javascript? ...

Is it possible to use a method from the parent class in the overwritten version in its child in javascript?

Is it possible to use a method from the parent class in the overwritten version in its child in javascript? ...

How to change implementation of returned object base class's function when object is returned C++

I have an existing application in C++ with a custom ArrayBase class that manages storage and access to a contiguously allocated region of memory. I have a separate ItrBase class that is used to access data in that ArrayBase. ArrayBase has a createItr() function that currently returns an ItrBase object. I need to extend ArrayBase to us...

Is it possible to declare a chain of super classes in interface declaration?

This may be a silly question but I haven't found any information on it. Let's say several of the classes in my program derive from 'MySubView' which is derived from another class, UIViewController. I would declare it like this: @interface NewViewController : MySubView { // code ... } @end In the future the client wants a change,...

Call base function then inherited function

I have a base class and a class inheriting base. The base class has several virtual functions that the inherited class may override. However, the virtual functions in the base class has code that MUST to run before the inherited class overrides get called. Is there some way that I can call the base classes virtual functions first then th...

Condition Based inheritance?

I am trying to inherit a set of different parent class and even not inherit any class but as per some condition. For example, Here is what I would like to do $choice = 2; switch($choice) { case 1: class child extends parent1 break; case 2: class child extends parent2 break; default: ...