Skip to content

Commit 0b8a5e2

Browse files
committed
.
1 parent 1e90481 commit 0b8a5e2

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

Advanced-Cpp-Programming.vcxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<ClInclude Include="Template Classes and Functions\Template-class.h" />
135135
</ItemGroup>
136136
<ItemGroup>
137-
<ClCompile Include="Cpp%2711 New features\Lambda-capture-expressions.cpp" />
137+
<ClCompile Include="Cpp%2711 New features\Capturing-this-with-lambdas.cpp" />
138138
<ClCompile Include="Operator Overloading\Complex.cpp" />
139139
</ItemGroup>
140140
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

Advanced-Cpp-Programming.vcxproj.filters

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<ClCompile Include="Operator Overloading\Complex.cpp">
3333
<Filter>Source Files</Filter>
3434
</ClCompile>
35-
<ClCompile Include="Cpp%2711 New features\Lambda-capture-expressions.cpp">
35+
<ClCompile Include="Cpp%2711 New features\Capturing-this-with-lambdas.cpp">
3636
<Filter>Source Files</Filter>
3737
</ClCompile>
3838
</ItemGroup>

Cpp'11 New features/Capturing-this-with-lambdas.cpp

+15-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@ using namespace std;
77

88
class Test {
99
private:
10-
int one;
11-
int two;
10+
int one{1};
11+
int two{2};
1212

1313
public:
1414
void run() {
15-
int three = 3;
16-
int four = 4;
15+
int three{3};
16+
int four{4};
17+
18+
auto pLambda = [this, three, four]() {
19+
one = 111;
20+
two = 222;
21+
cout << one << endl;
22+
cout << two << endl;
23+
cout << three << endl;
24+
cout << four << endl;
25+
};
26+
pLambda();
27+
1728
}
1829
};
1930

0 commit comments

Comments
 (0)