For a class Foo, is there a way to disallow constructing it without giving it a name?
For example:
Foo(\"hi\");
And only allow it i
Simply don't have a default constructor, and do require a reference to an instance in every constructor.
#include using namespace std; enum SelfRef { selfRef }; struct S { S( SelfRef, S const & ) {} }; int main() { S a( selfRef, a ); }