struct base
{
int num;
char ch;
float fl;
};
struct ss : virtual base
{
};
void main()
{
ss sa;
sa.num = 100;
cout << sa.num << endl;
memset(&sa, 0, sizeof(sa)); // set all members to zero
cout << sa.num << endl; // Access violation reading location 0x00000004.
}
I can access members from a struct that is derived from a virtual base. When zeroing out the struct it also causes the lost of access to the members. Does this mean we would have to clear members individually instead of using memset or ZeroMemory?