Topic: Is this a language quirk/Compiler quirk/my misunderstanding ?


Author: kavuri@lips.ecn.purdue.edu (Surya N Kavuri )
Date: 17 Dec 1994 15:40:05 GMT
Raw View
When compiled with MSVisualC++, class N and O had no errors while
class R had an error ? Should not class ) show an error too ?

class N
{
  protected:
    N() { }

  private:
    int d;
};

class O
{
  public:
    N n;
};

// comments: though the constructor of N is protected
// class O compiles!!

class R
{
  public:
    R() { }
    N n;
};
// Error:  'N::N' : cannot access protected member declared in class 'N'