Skip to content

Category Archives: C++

Standard C library provides qsort() that can be used for sorting an array. As the name suggests, the function uses QuickSort algorithm to sort the… Read More
Write a C program that doesn’t terminate when Ctrl+C is pressed. It prints a message “Cannot be terminated using Ctrl+c” and continues execution. We can… Read More
C++ supports function overloading, i.e., there can be more than one function with the same name but, different parameters. How does the C++ compiler distinguish… Read More
To calculate time taken by a process, we can use clock() function which is available time.h. We can call the clock function at the beginning… Read More
Write a program to Validate an IPv4 Address. According to Wikipedia, IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each… Read More
Given some text lines in one string, each line is separated by ‘\n’ character. Print the last ten lines. If number of lines is less… Read More
Static keyword is used for almost the same purpose in both C++ and Java. There are some differences though. This post covers similarities and differences… Read More
We can print 1 to 100 without using loops and recursion using three approaches discussed below: 1) Template Metaprogramming: Templates in C++ allow non-datatypes also… Read More
Predict the output of following C++ programs. Question 1 #include <iostream> using namespace std;    template <int N> class A {    int arr[N]; public:    virtual… Read More
We have discussed assignment operator overloading for dynamically allocated resources here. In this article, we discussed that when we don’t write our own assignment operator,… Read More
The answer is same as Copy Constructor. If a class doesn’t contain pointers, then there is no need to write assignment operator and copy constructor.… Read More
Function overloading is a feature of object-oriented programming where two or more functions can have the same name but different parameters. When a function name… Read More
  Multiple Inheritance is a feature of C++ where a class can inherit from more than one classes.  The constructors of inherited classes are called… Read More
We have discussed a similar topic in Java here. Unlike Java, C++ allows to give more restrictive access to derived class methods. For example the… Read More
Predict the output of following C++ programs. Question 1 #include<iostream> using namespace std;    class Base  { public:     int fun()      { cout << "Base::fun() called";… Read More

Start Your Coding Journey Now!