EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Question
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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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.
Chapter 1 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Knowledge Booster
Similar questions
- User-defined functions, rather than pre-defined ones, are more efficient.arrow_forwardIn what scenarios would it be beneficial to utilize a function object over a standard function?arrow_forwardWhen arrays are supplied to functions as parameters: A They are never passed by reference.B. They are usually passed by reference.C. Arrays cannot be sent as arguments to functions.D. There is no need to supply arrays to functions because they are global by default.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning