A virtual function is a member function of a base class that is overridden by a derived class. When you use a pointer or a… Read More
Category Archives: C++
Pre-requisite: Type Conversion in C++ and Use of explicit keyword in C++ A conversion constructor is a single-parameter constructor that is declared without the function… Read More
Inheritance in C++: This is an OOPS concept. It allows creating classes that are derived from other classes so that they automatically include some of… Read More
In C++, RTTI (Run-time type information) is a mechanism that exposes information about an object’s data type at runtime and is available only for the… Read More
In C++, class variables are initialized in the same order as they appear in the class declaration. Consider the below code. #include<iostream> using namespace… Read More
Ideally delete operator should not be used for this pointer. However, if used, then following points must be considered.1) delete operator works only for objects… Read More
delete and free() in have similar functionalities programming languages but they are different. In C++, the delete operator should only be used either for the… Read More
Following are the differences between malloc() and operator new.: Calling Constructors: new calls constructors, while malloc() does not. In fact primitive data types (char, int,… Read More
In C++, a static member function of a class cannot be virtual. Virtual functions are invoked when you have a pointer or reference to an… Read More
Calling an undeclared function is a poor style in C (See this) and illegal in C++and so is passing arguments to a function using a… Read More
Write a program that accepts a number from the user and prints “Even” if the entered number is even and prints “Odd” if the number… Read More
No, the C++ compiler doesn’t create a default constructor when we initialize our own, the compiler by default creates a default constructor for every class;… Read More
Reference Variables: You can create a second name for a variable in C++, which you can use to read or edit the original data contained… Read More
Local Variable: The variable whose scope lies inside a function or a block in which they are declared. Global Variable: The variable that exists outside… Read More
A copy constructor is a member function that initializes an object using another object of the same class. (See this article for reference). When should… Read More