Last active
December 21, 2015 12:28
-
-
Save plonk/6305646 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
| #include <functional> | |
| using namespace std; | |
| class Object | |
| { | |
| friend int main(); | |
| public: | |
| Object(string data) : _data(data) {} | |
| void instance_eval(function<void(Object*)> block) | |
| { | |
| block(this); | |
| } | |
| private: | |
| string _data; | |
| }; | |
| int main() | |
| { | |
| Object obj("SECRET"), obj2("DATA"); | |
| auto block = [](Object *_this){ cout << _this->_data << endl; }; | |
| obj.instance_eval( block ); | |
| obj2.instance_eval( block ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment