Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of overloaded operator in C++
#include <iostream>
using namespace std;
int main () {
int a = 5;
int b = 10;
char c = 'c';
char d = 'd';
bool t = true;
bool f = false;
cout << "int + int = " << (a + b) << endl;
cout << "char + char = " << (c + d) << endl;
cout << "int + char = " << (a + c) << endl;
cout << "bool + bool = " << (t + f) << endl;
cout << "int + char + bool = " << (a + c + t) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.