E Balagurusamy Object Oriented Programming With C++
Author:object oriented programming & c++
Language: eng
Format: epub
Tags: Programming
Pure Virtual Functions
C opy rig hted m ateri al
Object-Oriented Programming with C++
SUMMARY
to Polymorphism riimply means one name having multiple forms.
to "There art two types of polymorphism, namely, compile lime polymorphism and run time polymorphism.
to Functions and operators overloading are examples of compile time polymorphism, The overloaded member functions are selected for invoking by matching arguments, both type and number. The compiler knows this information at the compile time and, therefore, compiler is able to select the appropriate function for a particular c«ll at the compile time itself. This is called early or static binding ut static linking, it means that an object is bound to its function call at compile time.
to In run time polymorphism, an appropriate member function in selected w h ile Lhe program is running. C++ supports run time polymorphism with the help of virtual functions. It is called late or dynamic binding because the appropriate function is selected dynamically at run time. Dynamic binding requires use of pointers to objects and is one of the powerful features of C++-
to Object pointers are useful in creating objects at run time. It can be used to access the public members of an object, along with an arrow operator.
to A this [ mi nter refers to an object that currently invokes a member function. For example,
the function call lkIiqw( } will set the pointer 'this' lo thy: address of the object 'a'.
to Pointers to objects of a haee claw type are compatible with [jointers to objects of n derived class Therefore, we can use a single pointer variable to point to objects of base class as wall as derived classes.
to When a function is made virtual, C++ determines which function to use at run time based on the type of object pointed to by the base pointer h rather than the type of the pointer. By making the base pointer to point to different objects, we can exet-ute different versions of the virtual function.
to Run time polymorphism is achieved only when a virtual function is accessed through a pointer to the base class. It cannot be achieved using object name along with the dot operator to access virtual function,
O We can have virtual destmctorH but not virtual constructors.
to If a virtual function I5 defined in the base class, it need not be nen-.-; airily redefined in the derived class. In such cases, the respective calls will invoke the base class function.
to A virtual function* equated to zero is called a pure virtual function. It is a function declared in a base class that lias no definition relative to the base class. A class containing such pure function is called an abstract class.
Copyrighted material
Pointers, Virtual Functions and Polymorphism
*2G3
Key Terms
| Review Questions
9.1 What dw» polymorphism mean in C++ language?
%.2 How is polymorphism achieved at (a) compile time, and (b) run time ?
9.3 Discuss the different ways by which we can access public member functions of an
object,,
9.4 Explain, with an example, how you would create space for an array of objectn using pointers,
9.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12563)
Hello! Python by Anthony Briggs(9911)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9794)
The Mikado Method by Ola Ellnestam Daniel Brolund(9775)
Dependency Injection in .NET by Mark Seemann(9335)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8292)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7758)
Grails in Action by Glen Smith Peter Ledbrook(7693)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7016)
Microservices with Go by Alexander Shuiskov(6782)
Practical Design Patterns for Java Developers by Miroslav Wengner(6693)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6635)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Angular Projects - Third Edition by Aristeidis Bampakos(6043)
The Art of Crafting User Stories by The Art of Crafting User Stories(5572)
NetSuite for Consultants - Second Edition by Peter Ries(5507)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5309)
Kotlin in Action by Dmitry Jemerov(5061)
