answersLogoWhite

0


Best Answer

In its simplest definition, "binding", when referred to in the context of any computer programming language, describes how a variable is created and used (or "bound") by and within the given program and, possibly, by other programs, as well. However, there are other definitions for "binding" in computer programming languages, which would take too long to list and explain, especially given the broad nature of the question.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Most bindings in C (as opposed to C++ or other OO languages) is a static binding, done by the compiler at compile time.

This is because the compiler can determine the datatype when translating the program. Unlike a C++ program, sometimes a C++ program determines it's binding in a more dynamic way, at runtime. This is due to inheritance issues, which delay binding of a datatype in C++ to the actual run unit.

C does not have an object oriented, inheritance based environment, so the language bindings can be done at compile time and are static.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Static binding occurs at compile time. That is, when calling a non-virtual function, the compiler can determine the actual address of the function and statically bind to it.

By contrast, the compiler has no way of knowing which override of a virtual function will be called since this will ultimately be determined by the runtime class of the object. Thus the program must dynamically bind to the correct override by consulting that object's virtual table at runtime.

The only exception to dynamically binding to a virtual function is when the compile time class or any of its base classes declares the override to be final. In this case the compiler can statically bind to the final override since it is no longer a virtual function for the class that declared it final nor for any of its derivatives. Note that the final keyword was introduced in C++11.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Late binding means dynamic binding at runtime, and applies whenever the compiler does not have enough information in order to statically bind at compile time. For instance, when working with derived classes, you will generally work with pointers to their base classes since you cannot know what derivatives might exist in the future. But when you call virtual methods upon those base classes, the compiler cannot determine which override it will execute, so it cannot statically bind to those methods during compilation. Instead, it uses the derived class virtual table which will contain pointers to the actual overrides, and the program dynamically binds to the correct function at runtime.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Binding refers to the way member methods are bound to objects. Non-virtual functions are always statically bound while virtual functions are always dynamically bound via the virtual table. Every class that declares or inherits a virtual method has its own discrete virtual table that maps each virtual function to a function pointer, thus ensuring that the most-derived override is always executed first.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Dynamic binding occurs at runtime, whenever a type is unknown at compile time. For instance, if your code uses a pointer to an abstract data type, the actual type cannot be determined at compile time and must be dynamically bound at runtime. Static binding occurs at compile time, because the actual type is known in advance.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a static binding c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Static vs dynamic binding in c plus plus?

Static binding occurs at compile time. Dynamic binding occurs at runtime.


Does c and c plus plus support static or dynamic binding?

Yes and no. Static vs dynamic binding is not a C or C++ language issue; it is a linker issue. If you link with a .lib file that contains stubs for run-time loading, then the called routine will not be loaded until it is invoked, and it will not be made a part of the load module.


Which binding in C plus plus is preferred and why?

There is no preference as such. The type of binding you use is more dependant upon the design and circumstance rather than any preference you may have. Static binding is certainly more predictable and therefore easier to program, but dynamic binding offers much greater flexibility.


Why does C plus plus allows static binding and not dynamic binding?

Dynamic binding, or late binding, is when the object code for the class does not get loaded into memory until it is needed. This saves time at module load time, at the cost of delayed execution for the first invocation.


How ploymorphism and inheritance is different from that in Java and c plus plus?

C++ allows multiple inheritance while Java does not. In my opinion, multiple inheritance is not useful because it can get very confusing very quick. For polymorphism, C++ does early binding by default, while Java does late binding by default. Late binding is more useful than early binding.


What is storage classes in c plus plus?

AUTO EXTERN STATIC are the storage classes in c++


Difference between procedure and function in C or C plus plus or Java language?

In C there are functions only, In Java methodsonly (static methods as well), in C++ both.


Why you say that no static binding in php?

PHP supports late static binding since version 5.3, which was officially released in June of 2009.


Is late binding and dynamic binding related to polymorphism?

Late binding and dynamic binding are related to runtime polymorphism. By contrast, compile time polymorphism is known as static binding. Template functions and classes are examples of static binding because the exact type can be determined at compile time.


What is Difference between dynamic polymorphism and static polymorphism with example?

Static polymorphism is used the concept of early binding or we can say compile time binding where as dynamic polymorphism used the concept of late binding or run time binding.


What is meant by 'static' in C plus plus?

Static in C/C++ means that the variable will keep its value across calls to the function. ex: func() { static int x=0; ++x; cout << x << endl; } main() { func(); func(); func(); } This will print: 1 2 3 *NOT* 1 1 1


How do you write a program in c plus plus in which static variables are declared?

#include <stdio.h> static int myvar1, myvar2; int main (void) { puts ("It was easy"); return 0; }