Distinguish between static binding and dynamic binding. Explain the use of virtual func- tions and the vtable in dynamic binding.

What will be an ideal response?

Static binding is performed at compile time when a function is called via a specific object or via a pointer/reference to an object. Dynamic binding is performed at run-time when a virtual function is called via a base-class pointer/reference to a derived-class object (the object can be of any derived class). The virtual functions table (vtable) is used at run-time to enable the proper function to be called for the object to which the base-class pointer/reference “points”. Each class containing virtual functions has its own vtable that specifies where the virtual functions for that class are located. Every object of a class with virtual functions contains a hidden pointer to the class’s vtable. When a virtual function is called via a base-class pointer, the hidden pointer is dereferenced to locate the vtable, then the vtable is searched for the proper function call.

Computer Science & Information Technology

You might also like to view...

Microsoft's free file storage and file-sharing service is ________

A) OneDrive B) Office 365 C) OneNote D) SharePoint

Computer Science & Information Technology

Jen is working on a database that stores employee data. In the EmployeeData Table, there is a field that stores the number of years each employee has been with the company. She needs to design a query that shows all employees that have worked for company more than ten years. Which of the following query criteria should Jen use to locate is information and display records of employees with the

company more than ten years? A) =>10 B) >10 C) #10# D) <>10

Computer Science & Information Technology