inheritance

What are real-world examples of C++ multiple inheritance?

Besides textbook examples -- in the real world -- does it ever make sense to use multiple inheritance (where more than one of the base classes are not pure interfaces) in C++? ...

C++ multiple inheritance preventing diamond

Is there a way to define a class Foo in C++ so that I can inherit from it I can't "diamond inherit" from it I.e. class Cat: public Foo{} // okay class Dog: public Foo{} // okay class Weird: public Cat, public Dog {} // I want this to throw a compiler error ...

Get child class namespace from superclass in PHP 5.3

Assuming I have the following classes in different files: <?php namespace MyNS; class superclass { public function getNamespace(){ return __NAMESPACE__; } } ?> <?php namespace MyNS\SubNS; class childclass extends superclass { } ?> If I instantiate "childclass" and call getNamespace()...

Using Include() with inherited entities problem

In EF eager loading related entities is easy. But I'm having difficulties including inherited entities when loading data using table-per-type model. This is my model: Entities: ArticleBase (base article entity) ArticleSpecial (inherited from ArticleBase) UserBase (base user entity) UserSpecial (inherited from UserBase) Image R...

overriden virtual function is not getting called

a more exact version of the code is: class SomeParam; class IBase { public: virtual void Func(SomeParam* param = NULL) { cout << "Base func"; } }; class DerivedA : public IBase { public: void Func() { //do some custom stuff cout << "DerivedA func"; IBase::Func(); } }; class Deriv...

Some basic questions on constructors (and multiple-inheritance) in C++?

(I’m sorry if this has been asked before; the search feature seems to be broken: the results area is completely blank, even though it says there are a few pages of results… in Chrome, FireFox, and Safari) So, I’m just learning C++… and the book I’m moving through is doing a really bad job of explaining constructors in a way that I can g...

Why can't i set a member variable of an interface class as follows.

So i have a interface class class interfaceClass { public: virtual void func1( void ) = 0; virtual void func2( void ) = 0; protected: int m_interfaceVar; } and a class that inherits from it. Why can't i set the member variable of the interface class as follows. class inhertitedClass : public interfaceClass { inher...

XML differences between WCF and Python SUDS for inheritance?

Hello StackOverflow! This is my first post, so apologies if I don't include all the right information! I have a question regarding the different ways inheritance are represented between WCF and SUDS (Python). I have a C++/CLI WCF server (.NET 3.5 SP1) and I'm trying to communicate with it. I've used a C# (WCF also) client and it work...

allow using vector functions except one ??

i'm lost in this , i have a class that has three vector objects , class A { vector<int> h1; vector<double> h2; vector <int> h3; } i want to have (inherit ) all the vector functions ( push , size etc ) but EXCEPT " erase " function at first i made the objects public but then erase was available , i donno how inheritance...

Objective C: warning on overriding init

I have a class 'DOInstance' which I inherit later on. Here's its declaration: @interface DOInstance : NSObject { } - (DOInstance *) initWithSynckey:(NSString *)_synckey; @end Then I have a subclass of DOInstance: @interface Workflow_Workitem_Header_1px: DOInstance { } //- (Workflow_Workitem_Header_1px *) initWithSynckey:(NSString ...

C# root form inheritance, changes cause broken child forms

Hi I've setup a few subforms all inheriting from a root form that sets up a few buttons and logos etc to then filter down to the children. I used the visual studio wizard to add the subforms inheriting from the root and they are automatically declared with: public partial class WelcomeForm : MynetInstaller.rootForm I've now been a...

Class Hierarchy for Interfaces C#

I'm playing around with some classes and interfaces, and have developed a simple method to determine the hierarchy of a class, i.e. to identify the chain of inheritance. public static void OutputClassHierarchy(Type ty) { if (ty.BaseType == null) { Console.WriteLine("{0}: Base", ty); Console.WriteLine(""); ...

Create derived class instance from a base class instance without knowing the class members.

Is this scenario even possible? class Base { int someBaseMemer; }; template<class T> class Derived : public T { int someNonBaseMemer; Derived(T* baseInstance); }; Goal: Base* pBase = new Base(); pBase->someBaseMemer = 123; // Some value set Derived<Base>* pDerived = new Derived<Base>(pBase); The value of pDerived->someBase...

CSS Inheritance: Overriding a parent selector that is a decendant selector

How can I make this link use the child selector without changing or removing the parent selector? (I want the link to be blue.) <html> <head> <style> .parent a { color:Red; } .child { color:Blue; } </style> </head> <body> <div class="parent"> <a class="child" href=...

Use interface inheritance or just implement all the interfaces directly?

I don't necessarily see a grandiose benefit of interfaces inheriting interfaces. Consider the following three interfaces, the third inheriting the other two interface IOne { } interface ITwo { } // interface inheritance interface IAll : IOne, ITwo { } Is it best to class C : IOne, ITwo { ... } or class C : IAll { ... } If th...

Two questions related to Ruby threads

First one: how can I create a Thread that doesn't start right away.If I use initialize without a block an exception gets raised. how can I subclass Thread, so that I may add some custom attributes, but keep the same functionality as the base Thread class? I'd also like to not have to use the initialize(&block) method for this. To bet...

Resolve C++ virtual functions from base class

Hi, Sorry if this is a dupe, I cant find an answer quite right. I want to call a function from a base class member, and have it resolve to the subclass version. I thought declaring it virtual would do it, but it isn't. Here's my approach: class GUIWindow { public: GUIWindow() { SetupCallbacks(); } virtual void...

C++ How to assign / retrieve base class?

Suppose I have: class Foo { ... }; class Bar : public Foo { ... }; Foo foo; Bar bar; Is there anyway to do the following: foo_part_of_bar(bar) = foo; foo = foo_part_of_bar(bar); ? Thanks! ...

Mixing Inheritance and Tree Structure with Fluent nHibernate

Part of a model I'm designing is a hierarchy geographic locations. Since there are multiple layers and share some information I decided to use a class hierarchy like this: public class GeographicNode { public virtual int Id { get; private set; } public virtual string Name { get; set; } public virtual GeographicNode ParentNod...

Can I inherit an erb template?

Is there any way to have a template inherit another template? I'm not using Rails. ...