Created
July 12, 2018 01:30
-
-
Save daghlny/b7308cf2bd9dd8f548aec044d7324dad to your computer and use it in GitHub Desktop.
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 std::cout; | |
using std::endl; | |
struct add { | |
int sum; | |
add& operator()(int val) { | |
sum += val; | |
return *this; | |
} | |
add(int initval): sum(initval) {} | |
operator int() { return sum; } | |
}; | |
int main(void) | |
{ | |
cout << add(3)(4)(5) << endl; | |
if (add(3)(4)(5) == 12) | |
cout << "Perfect!" << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment