Created
June 25, 2018 17:11
-
-
Save haxscramper/7a1c285e2be6fea79408da7a7b5c2e39 to your computer and use it in GitHub Desktop.
C++ operator overloading.
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 <string> | |
#include <iostream> | |
struct Test { | |
std::string word; | |
Test& operator()() { return *this; } | |
std::string operator()(float f) { return word; } | |
Test& operator[](std::string w) { | |
word.append(w); | |
return *this; | |
} | |
}; | |
int main() { | |
Test test; | |
std::cout << test()["3"]()["34"]()["34534"]()["23"](3.4) << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment