Compiler diagnostic Visual Studio C++
C2259 cannot instantiate abstract class
The class still has at least one pure virtual function (= 0) without an implementation, so no object of it can be created. The messages that follow name each function still missing.
Visual Studio property-page paths describe MSBuild projects. For CMake, configure the corresponding target or preset. Menu names can vary by Visual Studio version; use the cited reference for your toolset.
error C2259: 'Circle': cannot instantiate abstract classCauses & corrections
Find the case that matches your build. Each example shows what changes and why.
A pure virtual function is not implemented.
Implement every pure virtual function of the base classes in the derived class.
Problem
struct Shape { virtual void draw() = 0; };struct Circle : Shape {};Circle circle;Correction
struct Shape { virtual void draw() = 0; };struct Circle : Shape { void draw() override {} };Circle circle;Note 1Implement all remaining pure virtual functions before instantiating the derived class. The signature differs from the base class.
A missing
const, another parameter type, or another calling convention declares a new function instead of overriding. Writeoverrideon each override: the compiler then reports the mismatch directly (C3668).Problem
struct Shape { virtual void draw() const = 0; };struct Circle : Shape { void draw() {} };Circle circle;Correction
struct Shape { virtual void draw() const = 0; };struct Circle : Shape { void draw() const override {} };Circle circle;Note 2Match constness and use override to catch signature mismatches. VideoFilmed in Visual Studio: this case fixed by hand, then with CppPilot. English narration, with subtitles in English, French, German, Italian and Spanish. Transcript
C2259, cannot instantiate abstract class: fixed by hand, then with CppPilot. Shape declares Area() const as pure virtual.
Square writes Area() without const: that is another function, so Square stays abstract, and the build fails with C2259. Give the override the same signature as the base class: add const.
Build again: Square now overrides Area, and the build succeeds. Now the same error, fixed by CppPilot.
After the failed build, select the error in the Error List, and click Fix with CppPilot. Click Fix on the C2259 card.
The AI compares Square::Area with the pure virtual function of Shape, and adds the missing const, with override. CppPilot rebuilds the project to check the fix: the error is resolved.
CppPilot explains and fixes C++ build errors in Visual Studio.
The base class is created directly.
Create the derived class, and use a pointer or a reference to the base.
Problem
struct Shape { virtual void draw() = 0; };Shape shape;Correction
struct Shape { virtual void draw() = 0; };struct Circle : Shape { void draw() override {} };Circle circle;Shape& shape = circle;Note 3Create a concrete class and access it through the abstract interface.
Sources and scope
Official references
These links document the compiler, build system, or debugger behavior discussed here. Use the version selector on Microsoft Learn for your toolset. Example blocks are focused excerpts; required headers and build settings are stated alongside them.
In your workspace
Investigate C2259 with CppPilot
CppPilot gives the selected AI the diagnostic, relevant code, and project settings for the active configuration. Choose Fix to request a correction, then check the result with a rebuild.
Use your own Codex or Claude account, or optional CppPilot Cloud access. Setup instructions
Visual Studio Marketplace