Talk:cpp/language/data members

A(int v) : v(v) { }    // OK const int& v = 42;      // OK

Better explanation is needed in both cases. The examples below are not enough.

A a1;   // error: ill-formed binding of temporary to reference A a2(1); // OK (default member initializer ignored because v appears in a constructor) // however a2.v is a dangling reference

Why example with dangling reference is needed? Not everybody understands what that means. Other strightforward example might be better.

50.34.185.97 16:53, 7 December 2016 (PST)
 * the example with the dangling reference is there to illustrate the sentence "Reference members cannot be bound to temporaries in a default member initializer", exactly because not everyone understands what it means. How would you make it more straightforward? --Cubbi (talk) 19:08, 7 December 2016 (PST)