This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Doesn't compile. Is it a bug?


This code doesn't compile. It complains that A::_say is protected when
in reality it's being used from B. calling A::_say works fine, but
obtaining the address fails compilation.

Thanks!

Juan Linietsky


-=-=-=-=- CODE --=-=-=-=-=-

#include <iostream>


class A {
protected:

 void _say() {}
public:

  virtual ~A() {};
};


class B : public A {
protected:

  void _say() { std::cout << "different pointers? " <<
(&A::_say!=&B::say) << std::endl; }

public:

  void say() { _say(); }
};


int main() {

  B b;
  b.say();

  return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]