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 exactly is an accessor function? What exactly is a mutator function? What are the conventions for naming such functions?
The effectiveness of user-defined functions much exceeds that of pre-defined ones.
True or False : The concept of function abstraction hinders our code development by confusing us with the details of the function.
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning