> I am not aware of any
> formally portable shortcut to avoid the error-prone
> listing of every member in the initialization-list:
> Foo():a(0),b(0),c(0),d(0),e(0),f(0),g(0),h(0),i(0),j(0),k(0){}
A little class like this one can be useful for classes where this is
an issue:
//auto-initialize POD types as well as class types
template
struct auto_zero {
T data;
operator T&() {return data;}
operator T const&() const {return data;}
struct A {
int i,j,k,l,m;
A() : i(), j(), k(), l(), m() {}
};
which can easily become a maintenance problem, you just do
struct A {
auto_zero i,j,k,l,m;
};
The automatic conversions make this completely transparent pretty much
99% of the time, occasionally you need an explicit cast, such as if
you want to use one of the variables in a switch statement.
-Lewis
Page2Go2.com is not responsible for content of this message.