
Why does the following compile? The parameter type of A's pure virtual function is private. How come B can see it, allowing it to override the pure virtual function? class A { private: struct S { }; virtual void bar ( S ) = 0; }; class B : public A { public: virtual void bar ( A::S ) { } }; int main ( ) { B b; return 0; } -Jason

Why does the following compile? The parameter type of A's pure virtual function is private. How come B can see it, allowing it to override the pure virtual function?
class A { private: struct S { }; virtual void bar ( S ) = 0; };
class B : public A { public: virtual void bar ( A::S ) { } };
int main ( ) { B b; return 0; }
-Jason Perhaps a question for comp.lang.c++. Remember to give the compiler, environment, and command-line you compiled it with. That said, it looks
Jason Hise wrote: like a compiler bug (but I'm not up to date on the standard's wording).

Simon Buchan wrote:
Jason Hise wrote:
Why does the following compile? The parameter type of A's pure virtual function is private. How come B can see it, allowing it to override the pure virtual function?
class A { private: struct S { }; virtual void bar ( S ) = 0; };
class B : public A { public: virtual void bar ( A::S ) { } };
int main ( ) { B b; return 0; }
Perhaps a question for comp.lang.c++. Remember to give the compiler, environment, and command-line you compiled it with. That said, it looks like a compiler bug (but I'm not up to date on the standard's wording).
Sorry, and never mind... I tested it on comeau and it failed to compile. It looks like it is just a bug with VC8. -Jason
participants (2)
-
Jason Hise
-
Simon Buchan