G
Gernot Frisch
Hi,
since C does not support construcor functions for structs, what is the
usual approach to write this C++ code in C:
I would write:
Any better ideas?
since C does not support construcor functions for structs, what is the
usual approach to write this C++ code in C:
Code:
struct foo
{
foo() {bar=0;}
int bar;
};
int main()
{
foo f[5];
}
I would write:
Code:
struct foo
{
bar;
};
Init(foo& f)
{
bar=0;
}
int main(int, char**)
{
foo f[5];
// Put this in a Macro: INIT(f)?
for(int i=0; i<sizeof(f)/sizeof(f[0]); ++i)
Init(f[i]);
return 0;
}
Any better ideas?