Answer the question
In order to leave comments, you need to log in
Does every cpp need to include main()?
Studying from the textbook, I saw this thing: "Every C++ program must include a main() function." Every cpp file must include a function main();
?
Answer the question
In order to leave comments, you need to log in
Only the main one.
In additional (where you just store the code so that the main file does not clutter up), of course, it is not necessary.
A program can consist of many cpp files, or maybe one, but main() is specified only once in all cases.
main in c++necessary because it is the entry point to the application. It should only be used in the main cpp file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question