According to the standard, you are not writing a true main function.
Section 3.6.1, paragraph 3: "The main function should not be used (3.2) inside the program. The connection (3.5) from main is determined by the implementation. The program declaring main to be inline or static is incorrect. The name main not otherwise reserved. [Example: member function, classes, and enumerations can be called by main , as well as objects in other namespaces.] "
This means that by declaring a member function main , you simply declare a member function. This is not significant and does not mean that anything in the class can be called independently. The program will mean exactly the same if you replaced snicklefrazz with this function name and all links.
Stylistically, snicklefrazz would be better since it would not lead to any possible output with the standard main function.
Section 3.6.1, paragraph 1: "The program must contain a global function named main , which is the designated start of the program. It is determined by the implementation whether the program is required in a stand-alone environment to determine main ."
This means that if you do not write what the standard calls a standalone environment (usually used when writing embedded systems), you need to define the global function main , and this is where the program starts.
In Java, a class can have a main method in which the program starts when the class is called. This does not apply to C ++, and there is no direct way to accomplish this.
(And, as others have noted, a class cannot be static , and a class definition ends with a semicolon.)
David thornley
source share