NAVI NING

The very beginning mind itself is the most accomplished mind of true enlightenment.

Container Adaptors

stack, queue and priority_queue

Container Adaptors Container adaptors provide a different interface for sequential containers. They do not have their own data structures. Instead, all their methods are implemented by the depende...

Sequence Containers

vector, deque and list

Sequence Containers Sequence containers implement data structures which can be accessed sequentially. There are three common sequence containers in STL: vector, deque and list. vector #include &...

Four Kinds of Type Conversions

What should type conversions be like in modern C++

Four Kinds of Type Conversions In C, we can cast a variable into a different type in such way: void main() { double a = 10.0; int b = (int)a; } However, this compulsory type conversion ...

Diamond Problem

A common issue in multiple inheritance

Diamond Problem The benefit of multiple inheritance is that more code can be reused in this inheritance structure. But it brings up another problem, which is known as diamond problem. Let’s look a...

Virtual Inheritance and Virtual Base Classes

What must be mastered in multiple inheritance

Virtual Inheritance and Virtual Base Classes Multiple inheritance means that a class can inherit from multiple base classes. Virtual Inheritance is a kind of inheritance that is widely used in mul...

Frequently Asked Interview Questions - Polymorphism

Common questions about polymorphism

Frequently Asked Interview Questions: Polymorphism Question 1 Here we defined a base class Animal, which has a member variable _name and a virtual function bark(). Then we defined three derived c...

Abstract Classes

Classes with pure virtual functions

Abstract Classes Let’s take another look at what we wrote earlier: class Animal { public: Animal(string name) : _name(name) {} virtual void bark() {} protected: string _name; }; clas...

Understanding Polymorphism

Why polymorphism is important in object-oriented programming

Understanding Polymorphism We already know that polymorphism is a key feature of Object-Oriented Programming, but what exactly is polymorphism? Why polymorphism is important? There are two kinds ...

More about Virtual Functions

Other things worth mentioning about virtual functions

More about Virtual Functions More about virtual Now we already learn the ability of virtual. But is there any function that cannot be implemented as virtual function? Notice that a virtual functi...

Virtual Functions, Static Binding and Dynamic Binding

How does C++ implement polymorphism

Virtual Functions, Static Binding and Dynamic Binding Static Binding Now suppose we have these two classes. Class Base has two methods show() and show(int), and class Derived has one method show(...