C++ / Documentation search
Find the error. Find the next step.
Search by diagnostic code, copied message, or symptom. Filter by content and project system.
205 results
Browse documentation →C2061: A dependent type in a template has no typename .
Write typename T::value_type : inside a template, a name that depends on a template parameter is not a type unless you say so.
C2061: The type is not declared at that point.
Include its header before the declaration, or qualify it with its namespace, for example std::string .
C2061: Two headers include each other.
With a circular include, the type is not declared yet. Forward-declare it ( class Widget; ) when the function takes a pointer or a reference, and include the header in the .cpp file.
C2065: Code comes before the precompiled header.
With precompiled headers, everything before #include "pch.h" is ignored. Make it the first line of the file.
C2065: The declaration is excluded by the preprocessor.
Check the #if or #ifdef around it and the preprocessor definitions of the configuration.
C2065: The declaration is in another scope, or comes later.
A variable declared inside a block or a loop does not exist after it, and a name must be declared before its first use.
C2065: The header that declares it is not included.
Include it in the file that uses the name, instead of relying on another header to include it.
C2065: The name is misspelled.
C++ is case-sensitive: Count and count are different names.
C2065: The name lives in a namespace.
Write std::cout , or add a using declaration.
C2084: A .cpp file is included.
Include headers, never .cpp files.
C2084: A function is defined in the class and again outside.
Keep one definition: either the body in the class, or a declaration in the class and the body in the .cpp file.
C2084: A header that defines functions has no include guard.
Add #pragma once to the header.
C2143: A class or struct definition does not end with ; .
Write }; after the closing brace. The error then appears on the first line after the class, often in another file that includes the header.
C2143: A type name is unknown.
In Widget* widget; , if Widget is not declared, the compiler reads it as a variable and expects ; before * . Include its header, qualify it with its namespace, or forward-declare it ( class Widget; ).
C2143: The previous statement is not finished.
Look at the line before the one reported: a missing ; , an unclosed parenthesis, or a macro that expands to something unexpected.
C2143: Two headers include each other.
One of the two classes is not declared yet when the other uses it. Replace one include with a forward declaration where a pointer or a reference is enough.
C2259: A pure virtual function is not implemented.
Implement every pure virtual function of the base classes in the derived class.
C2259: The base class is created directly.
Create the derived class, and use a pointer or a reference to the base.
C2259: The signature differs from the base class.
A missing const , another parameter type, or another calling convention declares a new function instead of overriding. Write override on each override: the compiler then reports the mismatch directly (C3668).
C2280: A class that contains one is copied.
A class with a unique_ptr member cannot normally be copied. If it has an available move constructor, move it into containers ( push_back(std::move(item)) ), or construct it with emplace_back . A user-declared destructor can prevent an…