Skip to content

Add example for C2102 #4968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions docs/error-messages/compiler-errors-1/compiler-error-c2102.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
---
description: "Learn more about: Compiler Error C2102"
title: "Compiler Error C2102"
ms.date: "11/04/2016"
ms.date: "03/03/2024"
f1_keywords: ["C2102"]
helpviewer_keywords: ["C2102"]
ms.assetid: d15b5fa3-fa46-4cd4-a3d2-3661646ecb7a
---
# Compiler Error C2102

'&' requires l-value

The address-of operator ( `&` ) must have an l-value as operand.
The [address-of operator (**`&`**)](../../cpp/address-of-operator-amp.md) must have an l-value as operand. Address of temporary values cannot be taken.

The following sample generates C2102:

```cpp
// C2102.cpp
int func()
{
return 1;
}

int main()
{
int* ptr = &func(); // C2102
}
```