I have a problem with Visual C ++ 2005, where the inner classes with the same name seem to be confused, but in different outer classes.
The problem arises for two layers, where each layer has a listener interface as an inner class. B is a listener of A and has its own listener in the third layer above it (not shown).
The code structure is as follows:
hijras
class A { public: class Listener { public: Listener(); virtual ~Listener() = 0; };
Bh
class B : public A::Listener { class Listener { public: Listener(); virtual ~Listener() = 0; };
A :: Listener () and A :: ~ Listener () are defined in A.cpp.
B.cpp
B::Listener::Listener() {} B::Listener::~Listener() {}
I get an error
B.cpp(49) : error C2509: '{ctor}' : member function not declared in 'B'
The C ++ compiler for Renesas sh2a has no problems with this, but then it is more liberal than Visual C ++, in some other respects too.
If I rename the listener interfaces to different names, the problem will disappear, but I would like to avoid it (the names of real classes instead of A or B are quite long).
Is what I'm doing right C ++, or is it an excuse for a Visual C ++ complaint?
Is there a way around this problem without renaming the listener interfaces?
source share