Skip to content

Instantly share code, notes, and snippets.

@plonk
Last active December 21, 2015 12:28
Show Gist options
  • Select an option

  • Save plonk/6305646 to your computer and use it in GitHub Desktop.

Select an option

Save plonk/6305646 to your computer and use it in GitHub Desktop.
#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