What are virtual functions? Describe a circumstance in which virtual functions would be appropriate.
What will be an ideal response?
Programmers use virtual function to enable generic processing of an entire class hierarchy of objects through a base-class pointer. If the program invokes a virtual function through a base-class pointer to a derived-class object, the program will choose the correct derived-class function dynamically (i.e., at execution time) based on the object type—not the pointer type. For example, in a shape hierarchy, all shapes can be drawn. If all shapes are derived from a base class Shape which contains a virtual draw function, then generic processing of the hierarchy can be performed by calling every shape’s draw generically through a base class Shape pointer. For this mechanism to work, each version of the virtual function throughout the class hierarchy must have the same function prototype.
You might also like to view...
The __________ mechanism assures that a received packet was in fact transmitted by the party identified as the source in the packet header and assures that the packet has not been altered in transit.
A) confidentiality B) authentication C) security D) key management
The SmartArt graphic type that shows proportional relationships is the ________
A) Hierarchy B) Pyramid C) Matrix D) Process
The MLA documentation style requires that you ____________________ the entire research paper; that is, the amount of vertical space between each line of text and above and below the paragraph should be equal to one line.
Fill in the blank(s) with the appropriate word(s).
When configuring a trunk between two switches, which dynamic trunking mode should be used to always initiate a trunking connection?
A) Dynamic active B) Dynamic desirable C) Dynamic auto D) Dynamic on