How to override a virtual member function which has the same name in two base classes

This problem doesn’t come up very often. The solution I’m familiar with was designed by Doug McIlroy and appears in Bjarne Stroustrup’s books (presented in both Design & Evolution of C++ section 12.8 and The C++ Programming Language section 25.6). According to the discussion in Design & Evolution, there was a proposal to handle this … Read more

Why should I avoid multiple inheritance?

Multiple inheritance (abbreviated as MI) smells, which means that usually, it was done for bad reasons, and it will blow back in the face of the maintainer. Summary Consider composition of features, instead of inheritance Be wary of the Diamond of Dread Consider inheritance of multiple interfaces instead of objects Sometimes, Multiple Inheritance is the … Read more

What are some good alternatives to multiple-inheritance in .NET?

You have two options here; use interfaces, or use composition. Honestly, interfaces are very powerful, and after reading this line The interface solution doesn’t make any sense to me. (Interfaces have never really made much sense to me, to be honest…) I think that you should learn how to use them properly. That said, if … Read more

C++ diamond problem – How to call base method only once

Most likely this is a XY problem. But … just don’t call it twice. #include <iostream> class Creature { public: virtual void identify() { std::cout << “I’m a creature” << std::endl; } }; class Swimmer : public virtual Creature { public: virtual void identify() override { Creature::identify(); tell_ability(); std::cout << “I’m a swimmer\n”; } virtual … Read more

Triple inheritance causes metaclass conflict… Sometimes

The error message indicates that you have two conflicting metaclasses somewhere in your hierarchy. You need to examine each of your classes and the QT classes to figure out where the conflict is. Here’s some simple example code that sets up the same situation: class MetaA(type): pass class MetaB(type): pass class A: __metaclass__ = MetaA … Read more

Typescript multiple inheritance

TypeScript 2.2 added support for the ECMAscript 2017 mixin pattern Here is a full code sample: // http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/ // https://github.com/Microsoft/TypeScript/wiki/What’s-new-in-TypeScript#support-for-mix-in-classes type Constructor<T> = new (…args: any[]) => T; class S { foo() { console.log(‘foo from S’); } } // Here the possible SuperClass is set to {} (Object) function Mixin1<T extends Constructor<{}>>(SuperClass: T) { return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)