VOOZH about

URL: https://www.geeksforgeeks.org/cpp/early-binding-late-binding-c/

⇱ Early binding and Late binding in C++ - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Early binding and Late binding in C++

Last Updated : 5 Feb, 2018
Binding refers to the process of converting identifiers (such as variable and performance names) into addresses. Binding is done for each variable and functions. For functions, it means that matching the call with the right function definition by the compiler. It takes place either at compile time or at runtime. 👁 cpp-binding
Early Binding (compile-time time polymorphism) As the name indicates, compiler (or linker) directly associate an address to the function call. It replaces the call with a machine language instruction that tells the mainframe to leap to the address of the function. By default early binding happens in C++. Late binding (discussed below) is achieved with the help of virtual keyword) Output:
In Base
Late Binding : (Run time polymorphism) In this, the compiler adds code that identifies the kind of object at runtime then matches the call with the right function definition (Refer this for details). This can be achieved by declaring a virtual function.
Output:
In Derived
Comment
Article Tags: