CPP Interfaces

Describing the behavior or capabilities of a class is the main purpose served by an interface in CPP. The CPP interface however, does not commit to any particular implementation of a class. To implement an interface in CPP, abstract classes are used. A abstract class is completely different from the concept of data abstraction. A … Read more

Categories CPP

CPP virtual function

A virtual function in CPP is used to perform dynamic linkage or late binding on a function. Late binding is used to resolve a function call during runtime, thus allowing the compiler to bind the function call at runtime after determining the type of object. A virtual function can be simply understood as a member … Read more

Categories CPP

CPP Function Overriding

Function overriding in CPP is the process of defining same function as defined in its base class in order to achieve runtime polymorphism. The advantage of using function overriding is that it provides the ability for specific implementation of the function, already provided by its base class. Example: #include <iostream.h> using namespace std; class State … Read more

Categories CPP

CPP Overloading

CPP overloading can be defined as the process of creating two or more members (methods, constructors and indexed properties) with same name and having parameters only but are different in number or type of parameter.   Types of CPP overloading:  Function overloading: In order to increase the readability of a program, function overloading is used. … Read more

Categories CPP

CPP Polymorphism

CPP introduced the features of OOPs Concept, i.e, CPP is an object-oriented programming language which uses classes and objects for computations. OOPs is based on the principle of Polymorphism, which means, that one task can be performed in many ways.   Types of CPP Polymorphism:  Compile time polymorphism: Compile type Polymorphism is a result of … Read more

Categories CPP

CPP Aggregation

The process of defining a class by some other class as any entity reference is termed as aggregation in CPP programming. In other words, aggregation can be defined as the process of reusing a class in a form of association. In CPP, the term aggregation means “HAS-A relationship.” Example: #include <iostream.h> using namespace std;   … Read more

Categories CPP

CPP Inheritance

The property of acquiring all the properties and behaviors of the parent object by an object is termed as inheritance in OOPs. This is a unique feature in object oriented programming languages which facilitates reusability of the code of the parent class by the derived class. CPP Multilevel Inheritance: CPP facilitates inheritance of a derived … Read more

Categories CPP

CPP Math Functions

Math functions and constants are already defined in the CPP library, in <math.h> header file, which can be used to perform mathematical calculations. CPP provides various math functions including; abs() function: This function is used to get an absolute value of a number. Syntax: abs ( number ) ceil() function: This function is used to … Read more

Categories CPP

CPP Friend Function

A function is called a friend function if the keyword friend is used with that function. The protected and private data of a class can be accessed using the friend function in CPP, if the function is declared inside the body of that class. Syntax: class class_name { friend data_type function_name(arguments); };   Example: #include … Read more

Categories CPP

CPP Enumeration

Enum is a data type defined in CPP library that can include fixed set of static and implicit constants like days of the week, directions etc. Advantages of using Enum: Improves type safety. Can be easily used in switch. Can be traversed. Can have fields, constructors and methods. May implement many interfaces but cannot extend … Read more

Categories CPP