Constructor: A constructor is a special member function of a class and shares the same name as of class, which means the constructor and class have the same name. The compiler calls the constructor whenever a class object is created; it allocates memory to the object and initializes class data members with default values or […]
October 13, 2022 | C++ | No comments
What is Function Overloading & why is it used? Function overloading is an object-oriented programming feature in which two or more functions have the same name but different parameters.The function overloading feature in C++ is used to improve code readability. It is used to save the programmer from having to remember multiple function names. Function […]
October 12, 2022 | C++ | No comments
What is the Inline function & why is it used? When the program executes the function call instruction, the CPU saves the memory address of the instruction that follows the function call, copies the function’s arguments to the stack, and transfers control to the specified function. This process can occasionally result in overhead in function […]
October 11, 2022 | C++ | No comments
Now, let’s look at some of the special member functions that can be defined in C++ classes. The following are the various types of Member functions: Simple functions Static functions Const functions Inline functions Friend functions Simple Member functions: These are the basic member function, which doesn’t have any special keyword like static etc. as […]
October 9, 2022 | C++ | No comments
A member function is a function that is declared as a class member. It is declared within the class in any of the visibility modes, i.e. public, private, or protected, and it has access to all the class’s data members. If the member function is defined within the class definition, it can be defined directly […]
October 9, 2022 | C++ | No comments
Members of a class can be accessed directly within the class by using their names. Accessing a member outside the class, on the other hand, is determined by its access specifier. The access specifier not only determines where the member is accessible in the program but also how it is accessible in the program. Note: […]
October 9, 2022 | C++ | No comments
Access modifiers, also known as Access specifiers, are used to implement Data Hiding, an essential aspect of Object-Oriented Programming. Data hiding is an important feature of Object-Oriented Programming that allows program functions to avoid directly accessing the internal representation of a class type. The labeled public, private, and protected sections within the class body specify […]
October 9, 2022 | C++ | No comments
The fundamental idea that the object-oriented approach revolves around in C++ is the concept of classes and objects. It increases the efficiency of the program by reducing code redundancy and debugging time. Classes: A class is the building block in C++ that leads to Object-Oriented programming. It is a user-defined data type with its own […]
October 4, 2022 | C++ | No comments
What are functions? A function is a collection of statements that accept input, perform some specific computation, and return output. The idea is to combine some frequently or repeatedly performed tasks into a function so that instead of writing the same code for different inputs, we can call the function. Advantages of functions: Code Reusability […]
October 2, 2022 | C++ | No comments
Storage classes in C++ are type specifiers that aid in defining the lifetime and visibility of variables and functions within a C++ program. C++ storage classes aid in determining the existence of a specific variable or function during the execution of a program. Syntax: Types of storage classes: Five different kinds of storage classes can […]
October 1, 2022 | C++ | No comments