Skip to content

Instantly share code, notes, and snippets.

@kateolenya
Last active April 25, 2019 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kateolenya/169aa64dd774dbeff0a585d9fc77faf4 to your computer and use it in GitHub Desktop.
Save kateolenya/169aa64dd774dbeff0a585d9fc77faf4 to your computer and use it in GitHub Desktop.
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