Category Archives: OOP with C++

39. Operator Overloading

Operator overloading is a compile-time polymorphism in which the operator is overloaded to provide the special meaning to the user-defined data type. Operator overloading is used to overload or redefines most of the operators available in C++. It is used to perform the operation on the user-defined data type. For example, C++ provides the ability… Read More »

38. Function Overloading

Function Overloading is defined as the process of having two or more function with the same name, but different in parameters is known as function overloading in C++. In function overloading, the function is redefined by using either different types of arguments or a different number of arguments. It is only through these differences compiler… Read More »

36. Overloading

If we create two or more members having the same name but different in number or type of parameter, it is known as C++ overloading.  In C++, we can overload: methods, constructors, and indexed properties It is because these members have parameters only. Types of overloading in C++ are: Function overloading Operator overloading C++ allows… Read More »

36. Encapsulation

All C++ programs are composed of the following two fundamental elements − Program statements (code) − This is the part of a program that performs actions and they are called functions. Program data − The data is the information of the program which gets affected by the program functions. Encapsulation is an Object Oriented Programming concept that… Read More »

35. Interface

An interface is a description of what member functions must a class, which inherits this interface, implement. In other words, an interface describes behavior of the class. You can imagine an interface as a list of functions that must be implemented by a class. An interface is created by using __interface keyword: __interface InterfaceName{ //group of functions… Read More »

34. Abstract Class

In C++ class is made abstract by declaring at least one of its functions as <>strong>pure virtual function. A pure virtual function is specified by placing “= 0” in its declaration. Its implementation must be provided by derived classes. Let’s see an example of abstract class in C++ which has one abstract method draw(). Its… Read More »

33. this Pointer

Every object in C++ has access to its own address through an important pointer called this pointer. The this pointer is an implicit parameter to all member functions. Therefore, inside a member function, this may be used to refer to the invoking object. Friend functions do not have a this pointer, because friends are not members of a class. Only member… Read More »

33. Destructors

What is a destructor? Destructor is an instance member function which is invoked automatically whenever an object is going to be destroyed. Meaning, a destructor is the last function that is going to be called before an object is destroyed. The thing is to be noted here, if the object is created by using new or… Read More »

32. Constructor Overloading

As we know function overloading is one of the core features of object-oriented languages. We can use the same name of the functions; whose parameter sets are different. Here we will see how to overload the constructors of C++ classes. The constructor overloading has few important concepts. Overloaded constructors must have the same name and… Read More »

31. Constructor

What is constructor?  A class constructor is a special member function of a class that is executed whenever we create new objects of that class. A constructor will have exact same name as the class and it does not have any return type at all, not even void. Constructors can be very useful for setting initial values… Read More »