Skip to content

Repo sync for protected CLA branch #4670

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 7 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
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
21 changes: 10 additions & 11 deletions docs/error-messages/compiler-errors-1/compiler-error-c2039.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
---
description: "Learn more about: Compiler Error C2039"
title: "Compiler Error C2039"
ms.date: "11/04/2016"
ms.date: "8/1/2023"
f1_keywords: ["C2039"]
helpviewer_keywords: ["C2039"]
ms.assetid: f9dfd521-9b36-4454-a69c-d63f45b606bb
---
# Compiler Error C2039

'identifier1' : is not a member of 'identifier2'
`'identifier1' : is not a member of 'identifier2'`

The code incorrectly calls or refers to a member of a structure, class, or union.

## Examples

The following sample generates C2039.
The following sample generates C2039:

```cpp
// C2039.cpp
Expand All @@ -28,7 +27,7 @@ int main() {
}
```

The following sample generates C2039.
The following sample generates C2039:

```cpp
// C2039_b.cpp
Expand All @@ -41,7 +40,7 @@ int main() {
}
```

The following sample generates C2039.
The following sample generates C2039:

```cpp
// C2039_c.cpp
Expand All @@ -57,9 +56,9 @@ int S::get_Count() { return 0; } // C2039
int S::Count::get() { return 0; } // OK
```

C2039 can also occur if you attempt to access a default indexer incorrectly. The following sample defines a component authored in C#.
C2039 can also occur if you attempt to access a default indexer incorrectly. To demonstrate, this code defines a C# component that is used by the C++/CLI code that follows:

```
```c#
// C2039_d.cs
// compile with: /target:library
// a C# program
Expand All @@ -72,7 +71,7 @@ public class B {
};
```

The following sample generates C2039.
The following sample generates C2039 when it uses the previously defined C# component's default indexer incorrectly from C++/CLI:

```cpp
// C2039_e.cpp
Expand All @@ -89,7 +88,7 @@ int main() {
}
```

C2039 can also occur if you use generics. The following sample generates C2039.
C2039 can also occur if you use generics. The following sample generates C2039:

```cpp
// C2039_f.cpp
Expand All @@ -114,7 +113,7 @@ int main() {

C2039 can occur when you try to release managed or unmanaged resources. For more information, see [Destructors and finalizers](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Destructors_and_finalizers).

The following sample generates C2039.
The following sample generates C2039:

```cpp
// C2039_g.cpp
Expand Down
Loading