I have a program with multiple headers and cpp files, I want to call a function defined in the same file main is defined (from a function defined in another file). If I'm correct, the file with the main function never has a corresponding header, right? How would I do it?
Why wouldn't you be allowed to have a header for functions inside main.cpp
? Assuming main.cpp
defines main
and foo
, nothing prevents you from having a header containing the declaration of foo
.
In fact, some libraries and frameworks make their own main
. In cases like these, you just link against the library that contains the main
.
For example, if you look at the last example code of this page of Boost's Unit Test Framework, you will see there is no main
. The main
is already written for you inside the Boost Unit Test Framework library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.