class A has many fields:
class A{
int a0;
int a1;
int a2;
int a3;
A();
}
contructor A can clear field by field:
A:A()
{
a0 = 0;
a1 = 0;
a2 = 0;
a3 = 0;
}
but how do better?
One solution is
A:A()
{
memset(this, 0, sizeof(A));
}
but fields of subclass will not clear
Do not zero the whole object memory of a class object. You don't know what's in it. It can contain more than just the variables you defined in the class definition. You could zero out something important and cause yourself big problems.
In a really simple class with really simple objects inside it, you might get away with it, but it's still a bad idea.