Skip to content

Tag Archives: C++-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
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
The dot (.) operator is used for direct member selection via object name. In other words, it is used to access the child object. Syntax:… Read More
Pre-requisite: Operator Overloading in C++ Given two strings. The task is to concatenate the two strings using Operator Overloading in C++. Example: Input: str1 =… Read More
Given Q queries of type 1, 2, 3 and 4 as described below. Type-1: Insert a number to the list. Type-2: Delete only one occurrence… Read More
Which of the following operator functions cannot be global, i.e., must be a member function. (A) new (B) delete (C) Converstion 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 overlaoded 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