Created
December 1, 2012 19:25
-
-
Save ElemarJR/4184340 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> | |
| using namespace std; | |
| int main() { | |
| int var = 5; | |
| cout << "(before) var = " << var << endl; | |
| auto byvalue = [=] | |
| { | |
| // var = 4; resulta em erro de compilação | |
| cout << "(byvalue) var = " << var << endl; | |
| }; | |
| auto byreference = [&] | |
| { | |
| var = 3; | |
| cout << "(byreference) var = " << var << endl; | |
| }; | |
| byvalue(); | |
| byreference(); | |
| cout << "(after) var = " << var << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment