coderz.py

Keep Coding Keep Cheering!

Upcasting in C++

Upcasting is the process of creating the derived class’s pointer or reference from the base class’s pointer or reference. It refers to the process of converting a derived class’s reference or pointer to a base class’s reference or pointer. Upcasting is a safer casting technique than downcasting. It supports public inheritance, which allows references to […]

October 26, 2022 | C++ | No comments

Order of Constructor Call in C++

If we inherit a class from another class and create an object of the derived class, it is obvious that the derived class’s default constructor will be invoked, but first, the default constructors of all base classes will be invoked. The data members and member functions of the base class are automatically included in the derived […]

October 23, 2022 | C++ | No comments

Types of Inheritance in C++

There are 5 types of Inheritance in C++: Single inheritance Multiple inheritance Hierarchical inheritance Multilevel inheritance Hybrid inheritance Single Inheritance: A class derives from only one base class in single inheritance. This means that there is only one subclass descended from a single superclass. Syntax: Example: Output: Multiple inheritance: Multiple inheritance is a type of […]

October 23, 2022 | C++ | No comments

Inheritance in C++

Inheritance refers to a class’s ability to derive properties and characteristics from another class. One of the most important aspects of Object-Oriented Programming is inheritance. This also allows: Code reusability  Quick implementation time Runtime polymorphism In inheritance, there are two kinds of classes: A parent class, also known as a base class, is a class whose […]

October 21, 2022 | C++ | No comments

Class Members Pointers in C++

A pointer to a C++ class is created in the same way that a pointer to a structure is created, and to access members of a class pointer, use the member access operator ->. To better understand the concept of a pointer to a class, consider the following example: Example: Output: Pointer to Data Members […]

October 20, 2022 | C++ | No comments

Copy Constructor in C++

A copy constructor is a type of constructor that creates a copy of another object. If we want one object to resemble another, we can use a copy constructor. If no copy constructor is written in the program, the compiler will supply its own copy constructor.The copy constructor is used to − Initialize one object […]

October 19, 2022 | C++ | No comments

References in C++

C++ references allow you to give a variable a second name that you can use to read or modify the original data stored in that variable. Once a reference has been initialized with a variable, it can be referred to using either the variable name or the reference name. For instance, A variable can be […]

October 18, 2022 | C++ | No comments

Mutable keyword in C++

Mutable data members are those whose values can be changed in runtime even if the object’s type is constant. It is the polar opposite of constant. It is sometimes necessary to modify one or more data members of a class or struct using a const function, even if you do not want the function to […]

October 16, 2022 | C++ | No comments

const keyword in C++

Const keyword define constant values that cannot change while the program is running. A const variable must be assigned a value when it is declared. If we try to change its value after it has been initialized, we will get a compilation error. Use of const keyword with different parameters: Variables Pointers Function arguments and […]

October 16, 2022 | C++ | No comments

static keyword in C++

When the static keyword is used, variable or data members or functions can no longer be changed. It is allocated for the lifetime of the program. The static keyword can be used with: Static Variables: Variables in a function, Variables in a class Static Members of Class: Class objects and Functions in a class Static Variables in […]

October 14, 2022 | C++ | No comments

Advertisement