“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”
Compile Time Binding : In case of operator overloading and function overloading the name of the function is resolved during the compile time . Even if there are two or more functions with the same name the compiler mangles the name so that each function is uniquely identified . This has to be resolved at compile time and is known as compile-time binding or early binding.
Run Time Binding : In case of polymorphism (virtual functions) if a base class pointer(or reference) is allocated a pointer(or reference) of derived class the actual function called is determined only during runtime through the virtual table entry . This is runtime binding or late binding
Binding means assigning value to object.
Static binding: means value is assigned to object(functions in many cases) is assigned value(address of function that will be called) during compile time.
Dynamic Binding: Here in case of function calls, Compiler does not knows which function(code) will be executed on a function call because it depends on object who is calling the function. If the value of object which is calling function depends on program logic, function call cant be binded to function code during compile time.
Thanks.
Static binding: it makes link at compile time. It is also called early binding. In compile time polymorphism the compiler can recognize that which function call belongs to which function definition. It can identify this by the type and number of arguments in the function call.
So the compiler makes appropriate links at compile time.
Dynamic Binding :links can de determined only at runtime. In runtime polymorphism (it uses virtual functions to achieve this) using pointer to the base class and this can point to any derived class object as well as the base class object. This pointer is assigned at runtime then only it know that which function will be executed. According to the object assigned it will call function of the class which the object belongs to.
In runtime polymorphism for ex: while using virtual functions,the compiler wont be having knowledge about which function the casted base pointer is pointing to so the address of the function is resolved at the run time through a particular table called virtual table(vtable which holds the address of each function which is virtual and a pointer to the function).
I guess this is about dynamic binding and static binding.
Dynamic Binding :
The address of the functions are determined at runtime rather than @ compile time. This is also known as “Late Binding”.
Static Binding :
The address of the functions are determined at compile time rather than @ run time. This is also known as “Early Binding”
Static binding in C++ is achieved through Operator overloading where as runtime binding is achieved through virtual functions.
In static binding,the compiler decides which function to invoke during compile time itself.
Compile Time Binding : In case of operator overloading and function overloading the name of the function is resolved during the compile time . Even if there are two or more functions with the same name the compiler mangles the name so that each function is uniquely identified . This has to be resolved at compile time and is known as compile-time binding or early binding.
Run Time Binding : In case of polymorphism (virtual functions) if a base class pointer(or reference) is allocated a pointer(or reference) of derived class the actual function called is determined only during runtime through the virtual table entry . This is runtime binding or late binding
Binding means assigning value to object.
Static binding: means value is assigned to object(functions in many cases) is assigned value(address of function that will be called) during compile time.
Dynamic Binding: Here in case of function calls, Compiler does not knows which function(code) will be executed on a function call because it depends on object who is calling the function. If the value of object which is calling function depends on program logic, function call cant be binded to function code during compile time.
Thanks.
Static binding: it makes link at compile time. It is also called early binding. In compile time polymorphism the compiler can recognize that which function call belongs to which function definition. It can identify this by the type and number of arguments in the function call.
So the compiler makes appropriate links at compile time.
Dynamic Binding :links can de determined only at runtime. In runtime polymorphism (it uses virtual functions to achieve this) using pointer to the base class and this can point to any derived class object as well as the base class object. This pointer is assigned at runtime then only it know that which function will be executed. According to the object assigned it will call function of the class which the object belongs to.
in runtime polymorphism,what is done inside the program
In runtime polymorphism for ex: while using virtual functions,the compiler wont be having knowledge about which function the casted base pointer is pointing to so the address of the function is resolved at the run time through a particular table called virtual table(vtable which holds the address of each function which is virtual and a pointer to the function).
STATIC BINDING:: is the linking of an object to its associated methods as compile time.
DYNAMIC BINDING:: also termed late binding, will delay this linking until runtime.
Leave an Answer/Comment