+ 1

does all the code in C++ should be written inside main() function only....????except the class, function.....

27th Apr 2017, 8:11 AM
Paavan Gupta
Paavan Gupta - avatar
4 Answers
+ 9
main is a function. One that will be executed with highest priority (first). You can write other functions and procedures outside the main. Then you can call them from main or from each other
27th Apr 2017, 8:25 AM
Dinmukhamed Mailibay
Dinmukhamed Mailibay - avatar
+ 2
oh! now I understood thanks to you both!!!...... :-)
27th Apr 2017, 8:30 AM
Paavan Gupta
Paavan Gupta - avatar
+ 1
Main - it is a place where the compiler first goes to start processing. Function-created when u are using same set of statements again and again in main block classes- they are user defined datatypes
27th Apr 2017, 8:24 AM
Nantha
Nantha - avatar
+ 1
we must also remember that apart from global functions, C++ is one of the only languages which supports global variables and global constants. So, main is mandatory for a C++ program to compile, followed by classes and functions. If there is no main, its not a C++ program, it maybe a class which could later be used in some program(s).
27th Apr 2017, 9:08 AM
Krishneel Nair
Krishneel Nair - avatar