"tom_usenet" <tom_usenet@hotmail.com> ha scritto nel messaggio
news:4486d0hid5llmg5kj83d6ojkqg37ol36p9@4ax.com...[color=blue]
> On Fri, 18 Jun 2004 16:07:51 GMT, "mcassiani" <mcassiani@virgilio.it>
> wrote:
>[color=green]
> >Hi, again
> >
> >I have readed the answare, I don't like it.
> >What do you think about this solutions? obiusly it works
> >only for dynamic allocated data.
> >
> >class{
> > int a1;
> > ..
> >..
> > int a100
> > char v1[100]
> > ...
> > char v100[100]
> >
> > void *operator new(size_t size){
> > void *ptr=malloc(size);[/color]
>
> Instead:
> void* ptr = ::operator new(size);
>[color=green]
> > memset(ptr,0,size);
> > return ptr;
> > }[/color]
>
> What about operator new[]?
>[color=green]
> >}[/color]
>
> Again, setting all bytes to 0 won't necessarily work for all POD
> types, particularly for doubles (and theoretically for pointers too).
> How about this:
>
> class test
> {
> private:
> struct data_t
> {
> int mem1;
> double mem2;
> char mem3;
> double mem4[50];
> } data;
> public:
> test()
> :data(data_t()) //zero initialises data
> {
> }
> };
>
> Tom
> --
> C++ FAQ:
http://www.parashift.com/c++-faq-lite/
> C FAQ:
http://www.eskimo.com/~scs/C-faq/top.html[/color]
I have tested the binary double composition for x86 processor and HP-PARISC
and 0 init
work well.