NAVI NING

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

More about Inheritance

Function hiding and type conversions

More-about-Inheritance Function Hiding In the following example, class Base has two overloaded member functions show() and show(int). Class Derived inherit from Base, and has a member function sh...

Look inside Inheritance

The core of object-oriented programming

Look inside Inheritance Inheritance is the core of object-oriented programming. The essence of inheritance is code reuse. Let’s take a look at the following example: class A { public: int ma;...

Overloading of new and delete - Object Pool

A very useful design pattern for resource reuse

Overloading of new and delete: Object Pool We have already written an own-defined queue data structure MyQueue before, which maintains a dynamic array as its private member. This time, we are goin...

More about new and delete

Learn more about memory management mechanisms

More about new and delete new and delete are a couple of keywords in C++ for memory arrangement. Meanwhile, they are operators that can be overloaded as well. When new is used, the compiler will f...

Issues of Iterator Invalidation

What we must pay attention to when using iterators

Issues of Iterator Invalidation When using iterators, we need to pay attention to the validation of them. In some cases, the iterator may turns invalid, which is not easy to notice. For example, ...

Introduction to Iterators

A transparent interface of container traversal

Introduction to Iterators Using what we have learnt about operator overloading, we write a MyString class. This class resembles std::string, which maintains a char * type pointer, and implement ba...

Operator Overloading

One of my favorite c++ features

Operator Overloading Operator overloading is one of the most fancy feature in C++. It is is a specific case of polymorphism, where different operators can be overloaded so that object operations ...

Memory Allocators

Indispensable component in template containers

Memory Allocators Now using what we’ve learnt in template programming, we write a class MyVector which is a vector container similar to std::vector. The code is shown below. template <typename...

Class Templates

Common programming paradigm in large libraries

Class Templates Templates are also widely used for classes. For example, the Standard Template Library (STL) is a set of C++ template classes to provide common programming data structures and func...

Function Templates

Another important programming paradigm in C++

Function Templates Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one ty...