How is a field function of a struct allocated in terms of a memory it occupies in a memory segment that's allocated for a struct object?
If I have a struct
Code:
Struct A
{
char* string;
void Func();
};
and if I do
Code:
A a;
memset(&a ,0, sizeof(A));
a.Func();
Would that break the program, because the function pointer stored within the memory space for the struct object is totally nuked by the memset cal?
In other words, does the memory space allocated for a struct look anything like this?
memory for the structure object a
====
memory to store address string points to
-------
memory to store address a function pointer points to the function Func()
====
How is doing
different from using memset for initialization?