C++ Program That Defines a Class String and Overload == Operator to Compare Two Strings [Operator Overloading Concept]

#include<iostream> #include<stdio.h>                             //used for gets() #include<string.h>                           //used for strcmp() using namespace std; class String {         char str[20];         public:         void getdata()                            //function to read the string         {                 gets(str);         }         //operator function to overload comparison operator and compare two strings         int operator ==(String s)         …

C++ Program That Defines a Class String and Overload == Operator to Compare Two Strings [Operator Overloading Concept] Read More »

C++ program for overloading binary operators, addition, subtraction, multiplication, division and comparison

In this program we will first create a class demo that contains two float data members a and b. Values of objects d1 and d2 are entered by user and then arithmetic operations are performed on them by overloading binary operators and result is stored in object d3. The code for the program is given …

C++ program for overloading binary operators, addition, subtraction, multiplication, division and comparison Read More »