Skip to content

Instantly share code, notes, and snippets.

@ytakano
Created February 1, 2016 07:53
Show Gist options
  • Save ytakano/0072e555ff75f5a73c2a to your computer and use it in GitHub Desktop.
Save ytakano/0072e555ff75f5a73c2a to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <thread>
#include <functional>
class myclass {
public:
myclass() {
auto th = std::thread(std::bind(&myclass::print, this));
th.join();
}
void print() {
int a = 100;
auto f = [&] () {
printf("%d\n", a);
};
f();
}
};
int main()
{
myclass c;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment