0
How do do several programs in one file?
for example i write a program, and then i want to do a completely diffrent program, should I state int main () again?
6 odpowiedzi
+ 1
kumar Quiroz I don't clearly get what you said. If it's all in one source file, it's not several programs, but modules/namespaces/libraries instead.
A C++ program has 1 and only 1 function named main, which served as the entry point for the program.
+ 1
thank you :))
0
Each program will have their own project and groups of files, for example:
//Program 1
main.cpp
runGame.h
rungame.cpp
endGame.h
endGame.cpp
renderGraphics,h
renderGraphics.cpp
// Program 2
main.cpp
math.h
math.cpp
input.h
input.cpp
output.h
output.cpp
These all live in their own folder structures and are written completely separately.
0
I meant several programs in one file :)
0
for example
int main ()
{
int x=4;
cout<< x <<endl;
return 0;
}
/* now i want to do another program under the above program, should i state int main again? */
0
kumar Quiroz write your other statements after std::cout, before return 0, in main.