I tested on two compilers, and was surprised to see both support the following definition without complaint:
class A { A(); }; A::A::A() {} ^^^
Note that this also succeeds for methods, although it is flagged when the declaration is over-qualified.
Questions:
Updated Detail:
In case the original question was not clear or too short: I'm curious why redundant qualifications are permitted on the definition (emphasis also added above).
Clang an Apple's GCC 4.2 + LLVM were the compilers
Yes, it's allowed (§9/2):
The class-name is also inserted into the scope of the class itself; this is known as the injected-class-name. For purposes of access checking, the injected-class-name is treated as if it were a public member name.
For information about the reasoning that lead to class name inject, you might want to read N0444.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With