5

A colleague sent me code similar to the following:

#include <iostream>

class Weird
{
public:
    Weird();
};

Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird::Weird()
{
    std::cout << "Ok, this is weird.\n";
}

int main()
{
    Weird a;
}

It compiles and runs and produces "Ok, this is weird." I tried it with g++, clang, and msvc with online compilers and it works on all of them.

Why is the repeated class name qualifier accepted? Is this intended by the standard?

Fred Larson
  • 60,987
  • 18
  • 112
  • 174

0 Answers0