In C/C++, precedence of Prefix ++ (or Prefix –) has same priority than dereference (*) operator, and precedence of Postfix ++ (or Postfix –) is… Read More
Category Archives: C++
Predict the output of following C++ program. #include <iostream> using namespace std; int main() { int test = 0; cout << "First character "… Read More
A class declaration can contain static object of self type, it can also have pointer to self type, but it cannot have a non-static object… Read More
Every literal (constant) in C/C++ will have a type of information associated with it. In both C and C++, numeric literals (e.g. 10) will have… Read More
In C/C++, initialization of a multidimensional arrays can have left most dimension as optional. Except the left most dimension, all other dimensions must be specified. For… Read More
Let us discuss how the default virtual behavior of methods is opposite in C++ and Java. It is very important to remember that in the… Read More
In C and C++, comma is the last operator in precedence table. So comma should be carefully used on right side of an assignment expression.… Read More
Prerequisite: Pre-increment and post-increment in C/C++ In C++, pre-increment (or pre-decrement) can be used as l-value, but post-increment (or post-decrement) can not be used as… Read More
In C++, following are the general rules for operator overloading. 1) Only built-in operators can be overloaded. New operators can not be created. 2) Arity… Read More
In C++, assignment operator should be overloaded with self assignment check. For example, consider the following class Array and overloaded assignment operator function without self… Read More
Deleting a derived class object using a pointer of base class type that has a non-virtual destructor results in undefined behavior. To correct this… Read More
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
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