GCC can’t differentiate between operator++() and operator++(int)

Name lookup must occur first. In this case for the name operator++. [basic.lookup] (emphasis mine) 1 The name lookup rules apply uniformly to all names (including typedef-names ([dcl.typedef]), namespace-names ([basic.namespace]), and class-names ([class.name])) wherever the grammar allows such names in the context discussed by a particular rule. Name lookup associates the use of a name … Read more

Inherit interfaces which share a method name

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

Are Mixin class __init__ functions not automatically called?

Sorry I saw this so late, but class MixedClass2(SomeMixin, MyClass): pass >>> m = MixedClass2() mixin before base mixin after The pattern @Ignacio is talking about is called cooperative multiple inheritance, and it’s great. But if a base class isn’t interested in cooperating, make it the second base, and your mixin the first. The mixin’s … Read more

Inheritance from multiple interfaces with the same method name

By implementing the interface explicitly, like this: public interface ITest { void Test(); } public interface ITest2 { void Test(); } public class Dual : ITest, ITest2 { void ITest.Test() { Console.WriteLine(“ITest.Test”); } void ITest2.Test() { Console.WriteLine(“ITest2.Test”); } } When using explicit interface implementations, the functions are not public on the class. Therefore in order … Read more