Can not instantiate class as LHS value with qualified enum as argument (C++ VS2015)

Viewed 65

I'm a little bit supprised as i see this compilation error;

Here is the example:

class A
{
public:
  enum eA { eA1, eA2 };

  class B
  {
  public:
    B(eA e, int i = 0);
  };

  A(const B &b);
};

A::A(const B &b)
{
}

A::B::B(eA e, int i /*= 0*/)
{
}

int main()
{
  A::B b(A::eA1);        // OK
  A a0(b);               // OK
  A a1(A::B(A::eA1, 0)); // OK
  A a2(A::B(A::eA2));    //error C2751: 'A::eA2': the name of a function parameter cannot be qualified
  return 0;
}

As pointed in comments, A a2(A::B(A::eA2)); doesn't compile. Why? I'm not asking how to compile it. Why it doesn't compile?

It compiles, if first parameter type of class-B is not from class-A. for example with int it compiles.

1 Answers
Related