devxlogo

Function Binding

Function Binding

Question:
Is there a compiler or run-time option to specify whether to use static binding or dynamic binding for function calls? This option, if it exists, may actually override the virtual mechanism.

Answer:
No, such compiler option doesn’t (and shouldn’t) exist. The dynamic binding mechanism may be overriden explicitly when you use a fully qulaified name of a member function:

Date date;date.Date::Display(); //static binding

Even if Display() happens to be virtual, the fully qualified call above will resolve statically.

I see no reason why compilers would need this feature. The choice between static and dynamic binding is solely a programmer’s choice, and the binding is dynamic under very strict conditions:
1) the function is virtual.
2) the function is called through a pointer or a reference to an object.

Otherwise, the call is resolved statically.

See also  How to Avoid Money Transfer Scams  
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist