x()->g()->f();
All it requires is that the function returns a pointer to a struct which itself contains function pointers.
C also allows the dot form if you really want it:
x().g().f()
Now to make it a bit more usable, one needs a bit of planning so that either of these can be done:
x(&x_out).g(&g_out, x_out).f(&f_out, g_out); x(&x_out)->g(&g_out, x_out)->f(&f_out, g_out);
Where there is a VFT in each of the xxx_out structures, and the calls simply returns the VFT, while the whole abstraction is stored/returned via the out arguments.
All it requires is that the function returns a pointer to a struct which itself contains function pointers.
C also allows the dot form if you really want it:
Simply by returning structs, and for all compilers that I know if, such end up using a hidden pointers to structs.Now to make it a bit more usable, one needs a bit of planning so that either of these can be done:
(I'd suggest the latter is now the more readable of the two).Where there is a VFT in each of the xxx_out structures, and the calls simply returns the VFT, while the whole abstraction is stored/returned via the out arguments.