Skip to content

Tag Archives: Operator Overloading

Prerequisite: Operator Overloading in C++, Types of Operator Overloading When an object calls an operator function by passing an argument and the returned value of… Read More
Pre-requisite: Operator OverloadingGiven two matrix mat1[][] and mat2[][] of NxN dimensions, the task is to perform Matrix Operations using Operator Overloading.Examples:   Input: arr1[][] = {… Read More
Given N triangles along with the length of their three sides as a, b and c. The task is to count the number of unique… Read More
Pre-requisite: Operator Overloading in C++Given two strings, how to check if the two strings are equal or not, using Operator Overloading. Examples:  Input: ABCD, XYZ… Read More
Which of the following operator functions cannot be global, i.e., must be a member function. (A) new (B) delete (C) Conversion Operator (D) All of… Read More
#include<iostream> using namespace std;    class Point { private:   int x, y; public:   Point() : x(0), y(0) { }   Point& operator()(int dx, int dy);   void… Read More
Predict the output? #include<stdlib.h> #include<stdio.h> #include<iostream>    using namespace std;    class Test {     int x; public:     void* operator new(size_t size);     void operator delete(void*);     Test(int… Read More
Output of following program? #include <iostream> using namespace std; class Test2 {     int y; };    class Test {     int x;     Test2 t2; public:     operator… Read More
Predict the output #include<iostream> using namespace std; class A {     int i; public:     A(int ii = 0) : i(ii) {}     void show() {  cout <<… Read More
How does C++ compiler differs between overloaded postfix and prefix operators? (A) C++ doesn’t allow both operators to be overloaded in a class (B) A… Read More
Which of the following operators should be preferred to overload as a global function rather than a member method? (A) Postfix ++ (B) Comparison Operator… Read More
Which of the following operators are overloaded by default by the compiler in every user defined classes even if user has not written? 1) Comparison… Read More
Which of the following operators cannot be overloaded (A) . (Member Access or Dot operator) (B) ?: (Ternary or Conditional Operator ) (C) :: (Scope… Read More
How can we restrict dynamic allocation of objects of a class using new? (A) By overloading new operator (B) By making an empty private new… Read More