What could this possibly mean in C++11?
struct : bar {} foo {};
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First, we’ll take a bog-standard abstract UDT (User-Defined Type):
Let’s also recall that we can instantiate the UDT at the same time that we define it:
Let’s combine the examples, and recall that we can define a UDT that has no name:
We don’t need the proof about the anonymous UDT any more, so we can lose the pure virtual function. Also renaming
instancetofoo, we’re left with:Getting close.
Now, what if this anonymous UDT were to derive from some base?
Finally, C++11 introduces extended initialisers, such that we can do confusing things like this:
And this:
And, finally, this:
This is an unnamed struct deriving from bar, instantiated as foo with a blank initializer.