Topics
Operating System
- Basics of Operating System (OS)
- Basics of Operating System (OS)
- Windows NT
- Introduction to GNU/Linux (GNU Not Unix)
- File Systems and Its Types
- File Operations
- Access Methods in Operating System
- Allocation Methods
- Concepts Related to Process Management
- Concepts Related to Memory Management
- Ubuntu is One of the Most Popular GNU/Linux Distributions
- Access and Security Aspects of O.S.
Data Structures
C++ Programming
- Introduction to C++ Programming
- Idea Behind Object-Oriented Programming
- Object-Oriented Programming Approach
- Object-Oriented Terms and Concepts
- Classes and Objects
- Constructors and Destructors
- Functions in C + +
- Arrays in Data Structure
- Pointers in C++
- References in C++
- Strings in C++
- Inheritance
- Virtual Functions and Polymorphism
- Friends in C++
- Operator Overloading and Type Conversions
- Files and Stream
HyperTex Markup Language (HTML)
- Introduction to HyperText Markup Language (HTML)
- HTML Documentation
- Basics of HTML Tags
- Font Tags in HTML
- Lists in HTML
- Tables in HTML
- Images in HTML
- Links in HTML
- HTML Scripts
- Introduction to Virtual Function
- Introduction to Polymorphism
- Pointer to Object and Derived Class
- Rules for Virtual Functions
- Use of Virtual in C++
Virtual functions and polymorphism
Polymorphism
Polymorphism stands for 'many forms'. The concept of polymorphism is already implemented using the overloaded functions and operators. This is called early binding or static linking as the compiler already knows about the overloaded functions before runtime. Run Time Polymorphism is achieved through Virtual Functions.
This pointer
The keyword ‘this’ represents a pointer that points to the object for which this function was called.
For example : the function call
A.max();
will set the pointer this to the address of the object A. The pointer this acts as an implicit argument to all the member functions.
Virtual functions
When we use same function name in both the base and derived classes, the function in base class is declared as virtual preceding its normal declaration. 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. Thus, by making base pointer point to different objects, we can execute different versions of the virtual function.
Rules for virtual functions
- The virtual functions must be members of some class.
- They cannot be static members.
- They are accessed by using object pointers.
- We cannot have virtual constructors, but we can have virtual destructors.
- Virtual functions are defined in base class, they need not be redefined in derived class. 6. A virtual function can be a friend of another class.
