The question is purely theoretical. There is a class A, it is inherited from different interfaces that have the same name but are in different namespaces.

class A : public Iface, public SomeoneNamespace::Iface { // override pure virtual functions }; 

Not compiled, IntelliSense tells me that I have not redefined the purely virtual interface functions from the SomeoneNamespace namespace.

Actually, the question is: are identical interface names valid?

  • Are Iface and Iface from SomeoneNamespace the same, or have identical methods or fields? - koshachok
  • No, each of them provides only two methods for reading / writing, and none of the names is repeated. - isnullxbh
  • question about identical interface names? If yes, then I collected your code for the sake of interest - everything is going perfectly ( VS 2015 ) - Duracell
  • 2
    Need a minimal reproducible example . Yes, and IntelliSense is still to the compilation stage. - αλεχολυτ
  • 2
    @isnullxbh You write that "does not compile", then there is code. But you did not provide it in sufficient volume. - αλεχολυτ

2 answers 2

Namespaces ( namespace ) were just introduced in order to avoid name conflicts. If there is any ambiguity at the point of use (for example, due to the presence of several using namespace earlier by code) for any name (whether the name is a class, variable or function), then the compiler will explicitly let you know about it with a message like:

reference to 'Something' is ambiguous

In this case, using fully qualified names like Namespace::Something will avoid ambiguity. This means that it is completely irrelevant when there are identical names in different namespace .


IntelliSense tells me that I haven't redefined pure virtual functions.

The error of the lack of implementation of a pure virtual function occurs when trying to instantiate an object of an abstract class. When defining a class, it cannot occur, so interface inheritance (in terms of language) is implemented correctly.

  • Thank you, this is useful information! - isnullxbh

Yes, if these interfaces are from different namespaces, as well as there are no identical component interfaces (if there is, then inherit with virtual ).

  • Specify, please, about what identical components of the interfaces in question. And how this is resolved with the help of virtual . - αλεχολυτ