less than operator overloading in c++
inline function
inline bool operator>(const double someValue) const {
return volume() > someValue;
}
less than operator overloading in c++
inline function
inline bool operator>(const double someValue) const {
return volume() > someValue;
}
operator overloading in c++
// operator overloading in c++ **sudipnext**
#include <iostream>
using namespace std;
class complex
{
int real, img;
public:
complex()
{
real = 0;
img = 0;
}
void getData()
{
cout << "Enter the real part :- " << endl;
cin >> real;
cout << "Enter the img part:- " << endl;
cin >> img;
}
complex operator+(complex &x)
{
complex temp;
temp.real = x.real + real;
temp.img = x.img + img;
return temp;
}
void display()
{
cout << "The ans are :- " << real << " " << img << endl;
}
};
int main()
{
complex obj1, obj2, obj3;
obj1.getData();
obj2.getData();
obj3 = obj1 + obj2;
obj3.display();
return 0;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us