Sort in C++ standard template library

Two elements of complex data types are not directly comparable. Consider the student structure defined as below struct Student { int rollNo; char name[25]; char […]

Find minimum of 3 numbers without using comparator operator

How will you find minimum of three integers without using any comparison operator ?

Linked List Implementation of Stack in C++

Write a class which will implement the Stack data structure in C++. Give the declaration & definition of the class. Also define the Node. For […]

Printing something without modifying main

The below C++ code will print “Hello World”. #include <iostream> int main() { cout<<"Hello World"; } Without modifying main function, add code to print “Ritambhara” […]

Find the output of C++ Program

What will be the output of the below C++ program: // Template Function - Not taking class template <class T, int i> int myFun(){ T […]

Which of the two comparison is better

While comparing a variable with a constant (literal) in C/C++ language, which of the two ways of comparison should we use ? if( x == […]

Disallowing object creation on heap

Object of a class can be created dynamically on heap or statically on Stack or Data Area. If we have a class MyClass, then the below […]

Allowing only dynamic object creation on heap

Write a class, such that user can create its object on heap (using new) but user should not be able to create its object on […]

using delete operator on this

Can we use delete operator on this inside a class member function in C++, something like below: class TestClass { public: void myFunc() { delete […]

Find size of a struct without using sizeof operator

How will you find the size of a structure in C/C++ language without using sizeof operator. (Note: sum of sizes of all fields of a […]