That is the point of this - to not create vtables to allow memcpy'ing around. Usually alternative to virtual tables in C are discriminated unions. You have struct with enum type and union of all possible types. Then you switch based on type. This way you can memcpy it around because type is just an integer in memory:
| enum Type { Cat, Dog };
struct CatStuff { ... };
struct Dogtuff { ... };
struct Animal {
Type type;
union {
CatStuff cat;
DogStuff dog;
};
};
|
Of course you don't need to do that for whole contents of struct. Sometimes just one "SomeType type" member is enough without any unions. Then you simply do
switch on it at runtime to call appropriate function - this way resolving function call addresses will happen at runtime, in place where switch is and not stored inside struct.
This is most trivial way to do it. Other way is to design your structs to have everything you need ("fat structures"), or have array with variable amount of properties that you access individually.