What goes into main function?

Posted by Woltan on Stack Overflow See other posts from Stack Overflow or by Woltan
Published on 2011-01-12T11:23:37Z Indexed on 2011/01/12 11:54 UTC
Read the original article Hit count: 186

Filed under:
|
|

I am looking for a best practice tip of what goes into the main function of a program using c++. Currently I think two approaches are possible. (Although the "margins" of those approaches can be arbitrarily close to each other)

1: Write a "Master"-class that receives the parameters passed to the main function and handle the complete program in that "Master"-class (Of course you also make use of other classes). Therefore the main function would be reduced to a minimum of lines.

#include "MasterClass.h"
int main(int args, char* argv[])
{
MasterClass MC(args, argv);
}

2: Write the "complete" program in the main function making use of user defined objects of course! However there are also global functions involved and the main function can get somewhat large.

I am looking for some general guidelines of how to write the main function of a program in c++. I came across this issue by trying to write some unit test for the first approach, which is a little difficult since most of the methods are private.

Thx in advance for any help, suggestion, link, ...

© Stack Overflow or respective owner

Related posts about c++

Related posts about style