+ 1
does all the code in C++ should be written inside main() function only....????except the class, function.....
4 Réponses
+ 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
+ 2
oh! now I understood thanks to you both!!!...... :-)
+ 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
+ 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).