EBK DATA STRUCTURES AND ALGORITHMS IN C
EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
Question
Book Icon
Chapter 1, Problem 14E
Program Plan Intro

Virtual function member :

  • A member function that can be declared within a base class is known as virtual function.
  • A derived class can redefine a virual function member.
  • Preceding the function declaration, a keyword “virtual” is used for creating a virtual function in base class.
  • While inheriting a class with virtual function, the virtual function is redefined by the derived class as per its needs.
  • Virtual function call is been resolved at the run time whereas non virtual member functions resolves at compile time.
  • Virtual function call is computationally more expensive than function call that is non virtual.
  • Virtual functions use pointer invocation, indirection and a few extra instructions are required than normal member functions.
  • The constructor of any class that would contain virtual functions are been required to initialize a table of pointers to its virtual member functions.

Non-virtual function member :

  • Non virtual function members are resolved statistically.
  • Non virtual member function is been selected statically based on the type of pointer to the object.
  • Unlike virtual function member, no runtime activities happens in non virtual member functions, since the compiler resoles non virtual functions at compile time based on the type of pointer.

Blurred answer
Students have asked these similar questions
what are the rules for virtual function?
What exactly is an accessor function? What exactly is a mutator function? What are the conventions for naming such functions?
Describe the performance considerations when heavily utilizing function objects.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education