dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

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


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.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


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

 

 

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