Last active
April 25, 2019 10:46
-
-
Save kateolenya/169aa64dd774dbeff0a585d9fc77faf4 to your computer and use it in GitHub Desktop.
Example of overloaded operator in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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