+ 2

In C++, does everything have to be on the main function?

23rd Oct 2020, 7:45 PM
Sauron24
Sauron24 - avatar
8 Respostas
+ 3
No, you can create a void function out of the main(). For example this: https://code.sololearn.com/cQu8biG7lFxp/?ref=app
23rd Oct 2020, 8:23 PM
Ayoub Ab
Ayoub Ab - avatar
+ 3
Thanks again :D
23rd Oct 2020, 8:54 PM
Sauron24
Sauron24 - avatar
+ 2
Sauron24 when we want to declare a function without returning value, we use void ,for more informations see this : https://www.sololearn.com/learn/CPlusPlus/1635/?ref=app and this : https://www.sololearn.com/learn/CPlusPlus/1636/?ref=app
23rd Oct 2020, 8:52 PM
Ayoub Ab
Ayoub Ab - avatar
+ 2
Any function can be made recursive, not just main().
25th Oct 2020, 1:09 PM
Sonic
Sonic - avatar
+ 1
Thanks. And what does a void function do?
23rd Oct 2020, 8:37 PM
Sauron24
Sauron24 - avatar
+ 1
You can declare variables,function,externs outside main().
24th Oct 2020, 1:33 AM
Aditya rout
Aditya rout - avatar
+ 1
Nope, you can declare variables, functions, macros and ... out of the main function.
24th Oct 2020, 8:58 AM
Soheil
Soheil - avatar
+ 1
time - tick tock
25th Oct 2020, 5:27 PM
Elena IVANOVA
Elena IVANOVA - avatar