C
C
chuvakizit2020-07-03 12:36:42
C++ / C#
chuvakizit, 2020-07-03 12:36:42

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

2 answer(s)
R
Ronald McDonald, 2020-07-03
@chuvakizit

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.

D
Dmitry Pavlov, 2020-07-03
@Stalker31

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 question

Ask a Question

731 491 924 answers to any question