Is A::B::B::B::B...B::f() right ? Why could i do that?

Viewed 146

I don't know how to explain this:

namespace A
{
struct B
{
  static void  f()
  {
  }
};
}

int  main()
{
  A::B::B::B::B::B::B::B::B::B::B::f();
}

Why could i do :

A::B::B::B::B::B::B::B::B::B::B::f();

I don't understand it why it's happening.

1 Answers

It is due to injected-class-name

inside class B, B refers to class B, as B::B.

so A::B::B refers to class B. and so on.

Related