5 Jun
2008
5 Jun
'08
10:58 a.m.
I have a following situation: class X { type1 v1; type2 v2; ... typen vn; other_var ... public: X() : v1(this), v2(this), .., vn(this), other_var(1, 2, 3) { } }; I'm looking for suggestions on how to automatically initialize variables v1..vn with "this" being passed as the only argument to their constructor. In the ideal case, the programmer should not need to specify any constructor calls for v1..vn, so that the end result looks something like: class X { type1 v1; ... typen vn; other_var; public: X() : other_var(1, 2, 3) { // some "magic" arranges that v1(this) .. vn(this) is called } }; Thanks!