Ad Space — Top Banner

C2039

Visual C++ Programming Language

Severity: Minor

What Does This Error Mean?

C2039 means you referenced a member function or variable that does not exist in the type the compiler knows about at that point. The message reads: C2039: 'member': is not a member of 'type'. Common causes are typos in the member name, using the wrong variable type, or including only a forward declaration instead of the full class header.

Affected Models

  • Visual Studio 2015–2022
  • MSVC v14.x / v17.x

Common Causes

  • Typo in the member name — C++ is case-sensitive so getSize and GetSize are different
  • A forward-declaration-only header was included instead of the full class definition header
  • Calling a method on a base class pointer when the method is only defined in the derived class
  • The member was removed or renamed in a library update
  • Using a class from the wrong namespace that has a similar but different interface

How to Fix It

  1. Check the spelling and case of the member name exactly. Open the class definition and confirm the member exists with that exact name.

    C++ is case-sensitive. In Visual Studio, right-click the class name and choose Go To Definition to open the header and see all members.

  2. Check that you included the full class header, not just a forward declaration. A forward declaration does not expose the class members to the compiler.

    A forward declaration (class MyClass;) only tells the compiler the class exists. The full header (include MyClass.h) is required to access any member of the class.

  3. If the member belongs to a derived class, make sure your pointer or reference is declared as the derived type, not the base type.

    A Base* pointer only exposes members declared in Base. Cast to the derived type or declare the variable as Derived* if you need access to derived-only members.

Frequently Asked Questions

Why does C2039 appear after a library update?

Library authors sometimes rename or remove members between versions. C2039 identifies exactly which member is missing, making it easy to find the replacement in the library's changelog or documentation. Search the library's migration guide for the old member name.