admin 管理员组

文章数量: 1086019

When I try to create a new C++ class by right-clicking anywhere in the Solution Explorer, Add -> Class, it creates an empty .h file (no #pragma once) and there is no .cpp file. This is happening across all my C++ projects, which include cmake projects and generic console applications (all Windows). I am using Visual Studio 2022 Community 17.13.5.

I have tried repairing, updating, and reinstalling Visual Studio through the installer.

How can I fix this?

When I try to create a new C++ class by right-clicking anywhere in the Solution Explorer, Add -> Class, it creates an empty .h file (no #pragma once) and there is no .cpp file. This is happening across all my C++ projects, which include cmake projects and generic console applications (all Windows). I am using Visual Studio 2022 Community 17.13.5.

I have tried repairing, updating, and reinstalling Visual Studio through the installer.

How can I fix this?

Share Improve this question edited Mar 27 at 18:05 Remy Lebeau 601k36 gold badges507 silver badges851 bronze badges asked Mar 27 at 10:10 StyderStyder 1 2
  • 2 This is the one case where a screenshot of the "add class" dialog would actually help. – Botje Commented Mar 27 at 13:17
  • 1 Not all classes need a /.cpp file. Some are implemented purely in the header file. Perhaps that's the assumption and there's a way to subsequently add a implementation file? – Jesper Juhl Commented Mar 27 at 20:17
Add a comment  | 

1 Answer 1

Reset to default 0

I found the solution by going to Tools -> Import and export settings -> reset all settings -> then I reset both general and visual C++

本文标签: cWhy is quotAdd gt Classquot only creating a header file not a header and cpp fileStack Overflow