最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - Why is "Add -> Class" only creating a header file, not a header and cpp file? - Stack Overflow

programmeradmin7浏览0评论

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++

发布评论

评论列表(0)

  1. 暂无评论