As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center作为指导。
7年前关闭。
我对最佳C ++编码做法有疑问。我注意到,对于几乎所有应用程序,第一个/主.cpp文件都是“ main.cpp”。我的问题很简单,命名第一个/ main .h文件的最佳实践是什么? “ main.h”?
7年前关闭。
我对最佳C ++编码做法有疑问。我注意到,对于几乎所有应用程序,第一个/主.cpp文件都是“ main.cpp”。我的问题很简单,命名第一个/ main .h文件的最佳实践是什么? “ main.h”?
最佳答案
按照惯例,xxx.cpp
所需的声明放在xxx.h
或xxx.hpp
中。因此,在您的情况下为main.h
。
但是,您应该使用有意义的名称进行命名。
大多数时候,您的main.cpp
不会做很多事情,因为它将使用各种类。每个类可能都放在ClassName.cpp
中(尽管不一定)。因此,您可能不需要main.h
。
关于c++ - 最佳默认标题名称? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10670415/