+ 2
Can we create a c++ program without main function?
6 Answers
+ 8
"No you cannot unless you are writing a program in a freestanding environment (embedded environment OS kernel etc) where the starting point need not be main()
As per the C++ standard main() is the starting point of any program in a hosted environment."
http://stackoverflow.com/questions/7050925/is-it-possible-to-write-a-program-without-using-main-function
+ 8
#define sample main
int sample() {
// Your code.
return 0;
}
will work.
+ 4
You can, but atleast I prefer not to do it in Code::Blocks, as there the main is important.
Any other function will return you a warning - Undefined Reference to WinMain()...
But yes, the code may still run.
And I personally prefer a code without warnings...
+ 1
No. The main function(as the name suggest) is the main function. Without it its like there is no function to function. Lmao
+ 1
You don't need this in swift, which is a mix of objectiveC and C++
0
Yes, It would raise an error or be ignored, I think