Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 932
Ghasem Ramezani Avatar asked Dec 18 '20 13:12

Ghasem Ramezani


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.

like image 62
Jarod42 Avatar answered Sep 21 '22 13:09

Jarod42