J
Jacek Dziedzic
Hi!
A) Why isn't it possible to set a member of the BASE class in
an initialization list of a DERIVED class constructor (except for
'calling' the base constructor from there, of course)? I even
tried prefixing them with BASE:: but to no avail. Still it's
ok when I set them in the construtor body, not the init list.
Does this mean that it's a small advantage of the initialization
inside the constructor over initialization in the init list
(though I know the init lists are 'cleaner' in general).
B) Is it, on the other hand, possible (looks to me like it is)
to use the values of BASE class members to initialize DERIVED
class members in the initialization list?
C) I know the initialization lists do not support the syntax
to initialize structs all at once, but why they don't allow
to initialize struct *members* like in
foo::foo() : bar.x(0), bar.y(0) {};
is beyond me. Why aren't members of structs treated like
'ordinary variables'? I know it's easiest to add a constructor
to the struct and to use it in the init list, but I'm just
curious...
TIA,
- J.
A) Why isn't it possible to set a member of the BASE class in
an initialization list of a DERIVED class constructor (except for
'calling' the base constructor from there, of course)? I even
tried prefixing them with BASE:: but to no avail. Still it's
ok when I set them in the construtor body, not the init list.
Does this mean that it's a small advantage of the initialization
inside the constructor over initialization in the init list
(though I know the init lists are 'cleaner' in general).
B) Is it, on the other hand, possible (looks to me like it is)
to use the values of BASE class members to initialize DERIVED
class members in the initialization list?
C) I know the initialization lists do not support the syntax
to initialize structs all at once, but why they don't allow
to initialize struct *members* like in
foo::foo() : bar.x(0), bar.y(0) {};
is beyond me. Why aren't members of structs treated like
'ordinary variables'? I know it's easiest to add a constructor
to the struct and to use it in the init list, but I'm just
curious...
TIA,
- J.