I have a question about best C++ coding practices. I noticed that for almost all applications the first/main .cpp file is “main.cpp”. My question is simple, what is best practice for naming the first/main .h file? “main.h”?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
By convention, the declarations needed for
xxx.cppgo inxxx.horxxx.hpp. So in your case it would bemain.h.However, you should name it with whatever makes sense.
Most of the time, your
main.cppwon’t do much, because it would use various classes. Each class will probably go inClassName.cpp(although not necessarily). So you may not need amain.h.