Skip to content

Category Archives: C++

C++ programming language allows both auto(or stack-allocated) and dynamically allocated objects. In Java & C#, all objects must be dynamically allocated using new. C++ supports stack-allocated… Read More
  [Note: This was true for older versions of C but has been changed in C11 (and newer versions).  In newer versions, foo() is same… Read More
A virtual function is a member function that is declared in the base class using the keyword virtual and is re-defined (Overridden) in the derived… Read More
In C++ the default return type of main is void, i.e. main() will not return anything. But, in C default return type of main is… Read More
Predict the output of following C++ program. #include <iostream> using namespace std; int main(int a) {     cout << a << "\n";     return 0; } int… Read More
If we have a function in base class and another function with the same name in derived class, can the base class function be called… Read More
In C, data type of result of comparison operations is int. For example, see the following program. #include<stdio.h> int main() {     int x = 10,… Read More
When a derived class object is assigned to a base class object in C++, the derived class object’s extra attributes are sliced off (not considered)… Read More
One of the advantages of C++ over C is Exception Handling. Exceptions are runtime anomalies or abnormal conditions that a program encounters during its execution.… Read More
A virtual function can be private as C++ has access control, but not visibility control. As mentioned virtual functions can be overridden by the derived… Read More
Template in C++is a feature. We write code once and use it for any data type including user defined data types. For example, sort() can… Read More
The idea of Encapsulation is to bundle data and methods (that work on the data) together and restrict access of private data members outside the… Read More
Write a program that compiles and runs both in C and C++, but produces different results when compiled by C and C++ compilers. There can… Read More
Although C++ is designed to have backward compatibility with C, there can be many C programs that would produce compiler errors when compiled with a… Read More
Given a floating point number, write a function to count set bits in its binary representation. For example, floating point representation of 0.15625 has 6 set… Read More

Start Your Coding Journey Now!