Skip to content

Commit 2055c4d

Browse files
authored
Merge pull request #4968 from Rageking8/add-example-for-c2102
Add example for C2102
2 parents 4516872 + 2770b7b commit 2055c4d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
---
22
description: "Learn more about: Compiler Error C2102"
33
title: "Compiler Error C2102"
4-
ms.date: "11/04/2016"
4+
ms.date: "03/03/2024"
55
f1_keywords: ["C2102"]
66
helpviewer_keywords: ["C2102"]
7-
ms.assetid: d15b5fa3-fa46-4cd4-a3d2-3661646ecb7a
87
---
98
# Compiler Error C2102
109

1110
'&' requires l-value
1211

13-
The address-of operator ( `&` ) must have an l-value as operand.
12+
The [address-of operator (**`&`**)](../../cpp/address-of-operator-amp.md) must have an l-value as operand. Address of temporary values cannot be taken.
13+
14+
The following sample generates C2102:
15+
16+
```cpp
17+
// C2102.cpp
18+
int func()
19+
{
20+
return 1;
21+
}
22+
23+
int main()
24+
{
25+
int* ptr = &func(); // C2102
26+
}
27+
```

0 commit comments

Comments
 (0)