CPP Exception Handling

Exception handling is necessary in an efficient code, as if it is not handled properly, further execution of code stops as soon as any exception occurs. CPP provides numerous ways and features to handle these exceptions in CPP codes, which makes the code more vulnerable to exceptional situations. Exception can refer to any situation and … Read more

Categories CPP

CPP String Functions

String Functions are the built-in functions provided by CPP to operate and manipulate a string. CPP provides a number of string functions. Some of the MOST USED string functions are listed below:   FUNCTION SYNTAX USES strcpy() strcpy(destination, source) Copies a string from source to destination. strcat() strcat(string1, string2) Concatenates two strings. strcmp() strcmp(string1, string2) … Read more

Categories CPP

CPP Strings

A sequence of characters, internally stored in the form of an array of characters is called as string. Declaration of String: In CPP, a string can be specified in two ways: Character Array: A string declared as an array, where each character represents an element of that array, is called as Character Array. Syntax: char … Read more

Categories CPP

CPP Iterators

CPP facilitates another unique feature same as that of pointers, known as iterators. Iterators in CPP are used to access the container elements by traversing through one element to another element. Syntax 1: <Container_Type> :: iterator; Syntax 2: <Container_Type> :: const_iterator;   Iterator Functions: There are mainly two functions that are used for an iterator … Read more

Categories CPP

CPP Templates

CPP templates acts as a support for generic programming technique, where parameters in algorithms are of generic types and thus can work for a variety of data types. This feature in CPP is used to define the generic classes and generic functions.   Types of CPP Templates: Function Templates: In function templates, templates for a … Read more

Categories CPP

CPP Namespaces

A namespace in CPP is used to define a scope in order to differentiate similar functions, classes, variables etc. to define the context in which names are defined for the same name available in different libraries. Syntax: Defining Namespace namespace namespace_name { // code declarations }   Syntax: Calling the defined name namespace_name  :: code;  … Read more

Categories CPP

CPP Data Abstraction

CPP introduced the features of OOPs Concept, i.e, CPP is an object-oriented programming language which uses classes and objects for computations. However, it is not considered to be truly object-oriented programming language. An object oriented programming is based on seven fundamental principles, including data abstraction. OOPS Data Abstraction feature is used for hiding internal details … Read more

Categories CPP

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