answersLogoWhite

0


Best Answer

Late binding, or dynamic binding, occurs at runtime. Early binding, or static binding, occurs at compile time. The difference between the two is that, with early binding, the compiler knows exactly which function will be called in advance and can statically bind to that function during compilation. With late binding, the compiler does not know which function will be called in advance, it only knows the function signature. Thus the binding has to be done at runtime.

For example, if you call a virtual function of a base class, the compiler cannot determine in advance the exact type of the derivative (in some cases it may not be derived at all). All it knows is that you've called the base class method and that an override may or may not exist at runtime. Thus the exact method to be called will ultimately be determined at runtime, via the derived class' virtual table. Note that although the derived class is itself late bound (because the compiler cannot know the exact type of a derivative that may be made available in the future), only the virtual methods of the base class need to be late bound. Non-virtual methods can be statically bound, since they are never expected to be overridden.

Calling virtual methods is actually no different to using function pointers within your code (a virtual table is simply an array of function pointers, with one table per base class, and another for each of its derivatives). Again, the compiler cannot know in advance where a function pointer will actually be pointing at compile time, thus the call must be dynamically bound at runtime.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is late bound function call in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

A c plus plus statement that invokes a function is known as?

...a function call.


What do you call an object function in c plus plus?

method


What is int86 function in c plus plus?

It is DOS-specific function in TurboC to call an interrupt. See the built-in help.


Is a function call a form of branching in C plus plus?

No. A branch is akin to a goto statement in procedural programming. The code branches off to a new code segment, never to return. A function call is akin to a subroutine in structured programming. When the subroutine is finished, control is returned to the instruction immediately following the function call, just as if the function's code were inline expanded at the call site.


How do you use integration on a TI-84 Plus Silver Edition?

Press MATH then 9 (fnInt() enter the function comma enter the variable comma enter the lower bound comma enter the upper bound


What is meant by passing function to another function in c plus plus?

Just as pointers can point to variables, pointers can also point to functions. Thus you can pass function pointers to functions. In so doing, you can alter the behaviour of the function by having it call dynamically call arbitrary functions rather than just preset functions.


What is a call by reference?

In C++ (C Plus Plus), when you call by reference, you are directly accessing the data of the referenced object. When you pass an object to a function by reference, any and all alterations to the object made within the function carry through to the actual object.


Call by reference using pointer in c plus plus?

Example: void foo( MyClass& object ){} // function with call by reference signature MyClass* p = new MyClass(); // instantiate a pointer to MyClass foo( *p ); // call by reference using the pointer


What is a reference variable in c plus plus?

A reference variable in C++ is a formal parameter of a function call that automatically dereferences itself, as if it were a pointer, into a reference to the original value in the calling routine. You declare the reference type in the function declaration and prototype, but the compiler automatically adds the reference (&) operator on call, and the dereference (*) operator on use.


Is y plus x2 plus 1 a function?

That is not a function, although it does involve the function of addition. A function is something that is done to numbers.


What is calling by reference?

In C++ (C Plus Plus), when you call by reference, you are directly accessing the data of the referenced object. When you pass an object to a function by reference, any and all alterations to the object made within the function carry through to the actual object.


What are the building function in c plus plus?

There is no such term as "building function" in C++.