Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: C++
Expertise: Beginner
Nov 9, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Function Binding

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.

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.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date