>Date: Tue, 17 Mar 2020 18:12:32 +0000
>From: Ryan Nicholl <rnicholl@protonmail.com>
>
>Consider:
>
>class A : public B, public C
>{
>virtual int lock();
>};
>
>what happens if both B::lock and C::lock exist as virtual functions? we can override them both with one function... but what if they are interfaces that do different things and happen to use the same name?
>
>Suggestion, specific override specifier:
>
>virtual int lock_mutex() override(int B::lock());
>virtual int lock_device() override(int C::lock());

I would suggest a better syntax would reuse the = operator as used in constructors now:

virtual int lock_mutex() = int B::lock();
virtual int lock_device() = int C::lock();

Not a complete solution, so this might also be needed:

virtual int lock() = delete;

So:

A* a;
a->lock_mutex(); // calls B::lock()
a->lock_device(); // calls C::lock()
a->lock();     // compiler error, attempted to call deleted virtual function.
(static_cast<B*>(a))->lock(); // calls B::lock(), as usual


The next problem is "can you delete virtual functions from parent classes even if there is no conflict?" I don't know. Would it be a bad thing? I don't think so. And making sure conflicting function names are not called accidentally can only be a good thing. But I'm not a compiler developer.

Joe