Ok, so if thats the case, if your spreading code across .cpp files, don't they need a main function too?
or is it an extention of your' program? as in leaving off in your .cpp and continuing in the same spot in another file?
like this :
.cpp file #1
1 2 3 4 5 6
#include<iostream>
usingnamespace std;
int main()
{
int num;
cout << "Input a number" << endl;
main() is the entry point -- it's where your program starts. Your program can't start in more than one place, so you can't have more than one main() in your program.
Multiple source files keep the code organized by having code that does a specific job in one file, and keeping unrelated code in other files. It also speeds up compile time because you don't have to recompile the entire program when you change one source file.
They're not used as your example. Instead, you put different function bodies in .cpp files.
1 2 3 4 5 6 7 8 9 10 11
// main.cpp
#include <iostream>
#include "header.h" // your header file
int main()
{
MyFunction(); // calls a function in another cpp file
std::cin.get();
return 0;
}