Accessibility confusion
-
If code was personified, this'd be a lawsuit waiting to happen:
[code]
class SomeWidget
{
public:
class HelperClass;
SomeWidget(HelperClass &helper, /* args /);
/ ... /
private:
class HelperClass { / ... / };
/ ... */
};
[/code]
-
What that even does?
-
Better yet, is that a programming language or some weird psude-code you just invented?TIL you can write C++ code like that... I wonder if Java... nope. Seems like a nice feature to have. Where's my JSR proposal template?
-
What that even does?
It's invalid C++ that provokes a
‘class 'SomeWidget::HelperClass’ redeclared with different access
compiler error in a conformant compiler. Quoth ISO 14882:2011 (11.1p4, I'm pulling from the N3337 working draft though):When a member is redeclared within its class definition, the access specified at its redeclaration shall be the same as at its initial declaration. [*Example:* [code] struct S { class A; enum E : int; private: class A { }; // error: cannot change access enum E: int { e0 }; // error: cannot change access }; [/code]*—end example*]
TIL you can write C++ code like that
Yes, this is supposedly-C++. See above.I wonder if Java... nope. Seems like a nice feature to have. Where's my JSR proposal template?
MUHAHAHAHAHA! The evil ideas thread is that way though.