3

Possible Duplicate:
C++ inheritance - inaccessible base?
Why does the compiler select the base class constructor inside the template argument list?

class InterfaceA
{
public:
  virtual void f () = 0;
};

class A :
  private InterfaceA
{
public:
  void f () {}

};

class B :
  public A
{
private:
  /*::*/InterfaceA * m_a; // Adding "::" makes it work
};

GCC and VS2008 say ‘class InterfaceA’ is inaccessible. If i declare m_a with explicit global scope everything compiles fine.

upd: m_a is a pointer, not an object itself. In fact the question why can't i declare a pointer and why adding "::" solves this problem?

Community
  • 1
  • 1
fogbit
  • 1,961
  • 6
  • 27
  • 41
  • I don't think this is a duplicate - it asks about accessing the base class, not it's (inherited) members. But because the question is closed, I will answer here: Without the ::, you see the InterfaceA class with the inherited visibility (private, because of A), so you can't see anything inside of it, except public static functions. With the :: you are accessing it from the global namespace, and see it as if you were accessing it from the main function - the fact that it's inherited is ignored. – Nulano Sep 22 '15 at 20:25

0 Answers0