Static and Dynamic binding in C++ with Examples (Early and Late binding)

Binding in C++ means associating the call of a function with the definition of that function. There are two types of binding in C++: static and dynamic binding (early and late binding)
Static binding happens at compile-time and dynamic binding happens at run-time.

The main advantage of static binding is that the program runs a little bit faster, and if we use dynamic binding (because binding happens in run-time) our program runs a little bit slower.
The main advantage of dynamic binding is that it is very flexible, and it allows us to decide at run-time which function definition we want to invoke.

Static binding happens by default, and it is achieved via normal function calls, function overloading, or operator overloading.
Dynamic binding is achieved by using virtual functions or function overriding.

  • 00:00 - Intro
  • 01:14 - Easy way to find bugs and errors in your code
  • 02:10 - Introduction to static and dynamic binding in C++
  • 03:24 - Advantages and disadvantages of static and dynamic binding
  • 04:31 - How to achieve static and dynamic binding
  • 04:56 - Function overloading vs function overriding
  • 05:45 - Static binding code example
  • 08:58 - Dynamic binding code example

#cplusplus #programming #developer

Static and Dynamic binding in C++ with Examples (Early and Late binding)