Initialize data using memset

Posted by gkid123 on Stack Overflow See other posts from Stack Overflow or by gkid123
Published on 2010-03-26T19:20:40Z Indexed on 2010/03/26 19:23 UTC
Read the original article Hit count: 396

Filed under:

memset to initilize data member- What is the benefit of initializing this way? Does it work in this example? Does it work in general ? Is it a good idea in general?

class A {
public:
   A();
private:
   int a;
   float f;
   char str[35];
   long *lp;
};

A::A()
{
   memset(this, 0, sizeof(*this));
}

© Stack Overflow or respective owner

Related posts about memset