I have a small program with such simple code:
namespace override { using final = void(); } namespace final { using override = void(int); struct final { virtual override override; virtual ::override::final override; }; } int main() { struct final final : ::final::final { ::final::override override override final; ::override::final override final override; };
Unfortunately, it does not compile. I tried to compile it with the following code snippets:
// 1 struct override final { }; // 2 override : final { };
And both of these options compile fine. Is this a bug in my compiler (clang 3.4)? I also cannot understand why my source code does not compile.
See a live example .
Update: It was a joke for the April Fool, of course. Thanks to everyone who participated in the discussion. I also thank @ecatmur for his exact but too serious answer.
I wanted to get code that would look strange and at the same time compile with at least one compiler (because it would give respectability to my question). So my goal was not to create standard code. But as @Johannes Schaub-litb noted in the comments, this code has at least one problem that makes it poorly formed. String virtual override override; is a violation of the following rule (see Clause [basic.scope.class] 3.3.7 / 1 of the standard):
The name N used in class S must refer to the same declaration in its context and when reassessed in completed area S Diagnostics are not required to violate this rule.
As I see it, it can be rewritten as virtual ::final::override override; to become standard.
c ++ inheritance c ++ 11 clang
Constructor
source share