C++ Templates

Templates in C++ are the powerful feature that allows us to write generic programs (generic classes and generic functions). A single class or function is created to work with different data types using templates. We pass the data types in a function as a parameter so that repetition of the same code can be avoided … Read more

C++ Friend Function

There are private and protected members in a class that is inaccessible from outside of the class, constituting one of the concepts of object-oriented programming i.e. data hiding. However, these rules can be broken by a friend function. A function defined with a friend keyword is called a friend function. It can access both the … Read more

this Pointer in C++

In C++, this is a keyword that refers to the current instance of a class and this pointer holds the address or points to the current object of the class. Also, only the member functions have this pointer. Members like friend functions do not have this pointer as they are not members of the class. … Read more

Inheritance in C++

Inheritance is one of the most important concepts of object-oriented programming. In C++, inheritance is the process of deriving the properties and behaviors of one class to another class. It is like a child and parent where the child possesses the properties of the parent. The class which inherits the members of another class is … Read more

C++ Encapsulation

Encapsulation is defined as the wrapping up of data(variable) under a single unit. Encapsulation is an important concept of OOP in C++ that binds data and functions inside a class together that manipulate them. Data encapsulation leads to the important concept called data hiding. It makes sure that the ‘sensitive’ data are hidden from the … Read more

C++ Interface (Abstract classes)

The interface is implemented using an abstract class in C++, hence the word interface and abstract class are used interchangeably. Abstraction classes are the way to achieve abstraction and abstraction is a technique in programming to hide the internal details and only show the necessary functionalities. The classes with at least one pure virtual function … Read more

C++ Data Abstraction

Data abstraction is the process of hiding the details but only displaying the relevant information to the users. This is one of the main advantages of using abstraction. It is a programming way or a technique through which we can separate the interface with the implementation details. Take a real-life example:Suppose a person is typing … Read more

C++ Virtual Function

Virtual function in C++ is a member function in the base class that we redefined in a derived class. With the use of a virtual function, we ensure that the function is overridden. A virtual function lets the compiler know to perform dynamic linkage or late binding on the function (that is the called function … Read more

C++ Function Overriding

Function overriding allows us to define a function at a derived class that is already present in a base class. And that base is said to be overridden. Both derived and base class has the member function with the same name, same return type, and same arguments list. And the decision made to call the … Read more

C++ Overloading (Operator and Function)

C++ allows us to overload methods, constructor and indexed properties. The function or operator define with the same name but with different types of parameters s called overloading. C++ has two types of overloading and they are: Function overloading Operator overloading C++ Function overloading Function overloading is a feature of object-oriented programming where multiple functions … Read more