Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Early binding and Late binding

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 463
    Comment on it

    In C++ program the compiler converts every statement in machine language of one or more lines, during compiled time. Every line is provided with the unique address. So each function of the program is provided with the unique machine language address.
    Binding is defined as the process which is used to convert identifiers into machine machine language code.

    EARLY BINDING
    In early binding events occur at the compile time. It directly collaborate the identifier name with the unique address code. Early binding is also known as static binding. It is rapid and effective.

    E.g of early binding :

    
    #include 
    
    void PrintValue(int nA)
    {
        std::cout << nA;
    }
    
    int main()
    {
        PrintA(5); // This is a direct function call
        return 0;
    }
    
    


    LATE BINDING
    In late binding when a program is run it is not known that which function will be called till runtime. It is also known as dynamic binding. In late binding we use function pointer which does not point a variable, it points the function pointer using "()". The process is slow.

    E.g of late binding:

    int Add(int nA, int nB)
    {
        return nA + nB;
    }
    
    int main()
    {
        // Create a function pointer and make it point to the Add function
        int (*pFcn)(int, int) = Add;
        cout << pFcn(5, 3) << endl; // add 5 + 3
    
        return 0;
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: