How to get late binding in C language? Anyone can please provide an example.
I think it can be obtained using DLOPN and DSCIM but I am not sure about it. If I'm wrong then correct me!
In the late (aka dynamic) binding, dynamically-loaded modules (that is, Dlupun and DSCIM's There is nothing to do with). Instead, it is about the decision about how the function is called up to runtime.
In C, this function pointer is used (whichever is actually done for any C ++ implementation virtual function).
One way to emulate this is to pass the strings of the function points and then call the function through the function pointer.
Example:
typedef structure animal {say hello) (structure animal * one, const char * name); } animal; Stable Zero Quakkawk (Animals * A, Const four * names) {printf ("Quack quack% s, ducks on 0x% x! \ N", name, A); } / * This function uses late binding by the function pointer. * Hello / Hello (A, Name);} Int main () {struct animal duck = {& quotQUquQuak}; Show Greeting (and duck, "John"); Return 0;}
Comments
Post a Comment