All of this hair-splitting is unnecessary though, really - everyone here should have known what I meant from the very beginning. Instead, some chose to sift through my words like a pack of lawyers, for no other reason than to claim some hollow victory of semantics.
Touche!
Anyone may do as they are so enclined insofar as using either a main function directly or else by way of some class. Both surely have their own merits and disadvantages, but neither is "wrong", "incorrect", or "bad style". It's all just a matter of preference.
It's not hair splitting. I said "main is not part of a class" and you said "depends".
No, it doesn't depend. It's not part of a class. It's the entry point to every C++ program. That's all. There are no split hairs. It is always there. It's not part of a class. Period.
You didn't say "I make a class that I call from main and have it be the starting point for the remainder of my program."I didn't sift through your words. I took the first thing you said in reply to the first thing I said, and the first thing you said was wrong. Period. WRONG. There is no main "by way of some class".
Quzah.
Hope is the first step on the road to disappointment.
I can see where you are coming from, but consider GReaper's confusion expressed in post #9 that required clarifications from various people, including yourself. To be fair, quzah's statement was inaccurate too: a function named main can indeed be a member of a class; but the global main function cannot be a member of a class.Originally Posted by gardhr
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Your method might force the user to declare command line arguments and environment variables (not to mention a useless integer) to be passed along to the object. Mine does not. I have merely simplified a needlessly redundant artifice of C++ programming. How could that possibly be labeled "unnecessary"?
If "acting like a Greek" means being creative and open-minded, sure, I'll go with that. I don't prescribe to anything more than safe, intelligent coding practices. It that's a crime (and in Rome, everything seems to be), so be it. As they say, "I'll follow the Sun".
That isn't actually an advantage, and there would not necessarily be a "useless integer" passed with what I stated as more common in post #10.Originally Posted by gardhr
I don't see how it is "a needlessly redundant artifice" to begin with.Originally Posted by gardhr
You did not state the details earlier, so that was not clear, though I understood that you were not saying that there would not be a global main function at all. However, to someone with less knowledge of C++, it would and did seem that you were saying that there would not be a global main function. That's unfortunate, but having been clarified, so be it.Originally Posted by gardhr
What exactly do you mean by this? I understand it to mean that you define the main function in a header file that is included in exactly one source file.Originally Posted by gardhr
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Agreed.
Correct. From the header file, 'main' invokes a virtual function on a singleton pointer to the program's sub-base-class which then propagates the parameters to the actual (CRTP) base class, which is customizable via a 'traits' parameter (optionally) specified by the final derived class (to control the underlying container types to be used, etc; in case you want to use a map-type interface for the environment variables or what have you).