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

CPP Structs

Structs are blueprints in CPP. Like classes, CPP structs are used to create instance of a class, but are preferred only for lightweight objects which are not intended to any future modifications. The lightweight objects include, Rectangle, color, Point etc. A CPP class uses Call by Value method for calling while, CPP structs uses Call … Read more

Categories CPP

CPP static

There are a list of words already defined in CPP library, same as in C. These reserved words are called as CPP Keywords. Every keyword is defined to serve a specific purpose. CPP static is one such keyword, which is used as a storage class to represent the scope of a variable within the program. … Read more

Categories CPP

CPP this Pointer

In CPP library, this is a pre-defined keyword which is used to refer to the current instance of a class. Usage of CPP this Pointer: to pass current object as a parameter to another method. to refer current class instance variable. to declare indexers. Example: #include <iostream.h> using namespace std;   class Student { public: … Read more

Categories CPP