Skip to content

Commit 684eae2

Browse files
authored
Overhaul existing example in C2601 error reference
1 parent 20d467e commit 684eae2

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

docs/error-messages/compiler-errors-2/compiler-error-c2601.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ Or, there may be an extra/missing brace before the location of the C2601 error.
1818

1919
## Examples
2020

21-
The following sample generates C2601:
21+
## Define function within a function
2222

23-
```cpp
24-
// C2601.cpp
25-
int main() {
26-
int i = 0;
23+
[Lambda Expressions](../../cpp/lambda-expressions-in-cpp.md) may be used to emulate the behavior of local functions:
2724

28-
void funcname(int j) { // C2601
29-
j++;
30-
}
25+
```cpp
26+
// C2601a.cpp
27+
int main()
28+
{
29+
int increment(int value) // C2601
30+
{
31+
return value + 1;
32+
}
33+
34+
// Try the following line instead:
35+
// auto increment = [](int value) { return value + 1; };
36+
37+
int two = increment(1);
3138
}
3239
```

0 commit comments

Comments
 (0)