Category: CPP

Difference between Function Overloading and Function overriding in C++

Difference between Function Overloading and Function overriding in C++   Function overloading and Function overriding both are examples of polymorphism but they are completely different. Before we discuss the difference between them, lets discuss a little bit about them first. Function Overloading Function overloading is a feature that allows us to have same function more than once in […]

Function Overriding in C++ with examples

Function Overriding in C++ with examples Function overriding is a feature that allows us to have the same function in child class which is already present in the parent class. A child class inherits the data members and member functions of the parent class, but when you want to override functionality in the child class […]

Function overloading in C++ with examples

Function overloading in C++ with examples   Function overloading is a C++ programming feature that allows us to have more than one function having same name but different parameter list, when I say parameter list, it means the data type and sequence of the parameters, for example the parameters list of a function myfuncn(int a, float b) is (int, float) which […]

Polymorphism in C++ and its types

Polymorphism in C++ and its types Polymorphism is a feature of OOPs that allows the object to behave differently in different conditions. In C++ we have two types of polymorphism: 1) Compile time Polymorphism – This is also known as static (or early) binding. 2) Runtime Polymorphism – This is also known as dynamic (or late) binding. […]

Inheritance in C++ with examples

Inheritance in C++ with examples Inheritance is one of the features of the Object Oriented Programming System(OOPs), it allows the child class to acquire the properties (the data members) and functionality (the member functions) of parent class. What is child class? A class that inherits another class is known as child class, it is also […]

Destructors in C++ with examples

Destructors in C++ with examples A destructor is a special member function that works just opposite to constructor, unlike constructors that are used for initializing an object, destructors destroy (or delete) the object. Syntax of Destructor ~class_name() { //Some code } Similar to constructor, the destructor name should exactly match with the class name. A destructor declaration […]

Encapsulation in C++ with example

Encapsulation in C++ with example Encapsulation is a process of combining data members and functions in a single unit called class. This is to prevent the access to the data directly, the access to them is provided through the functions of the class. It is one of the popular feature of Object Oriented Programming(OOPs) that helps in data […]

Friend Class and Friend Functions in C++

Friend Class and Friend Functions in C++ As we know that a class cannot access the private members of other class. Similarly a class that doesn’t inherit another class cannot access its protected members. That is why we have “Friend Class and Friend Functions in C++”. Friend Class: A friend class is a class that can […]

Interfaces in C++ with Examples

Interfaces in C++ with Examples In C++, we use terms abstract class and interface interchangeably. A class with pure virtual function is known as an abstract class. For example, the following function is a pure virtual function: virtual void fun() = 0; A pure virtual function is marked with a virtual keyword and has = 0 after its signature. […]

Abstraction in C++ with example

Abstraction in C++ with example Abstraction is one of the features of Object-Oriented Programming, where you show only relevant details to the user and hide irrelevant details. For example, when you send an email to someone you just click send and you get the success message, what actually happens when you click send, how data […]