The main() Function

All C++ programs have a special function called main

The basic template for main is:

void main(void)
{   
  data declarations
  statements

}

You will see other headers for main such as:

int main()
void main()

If you use the int main() version, the final statement in main should be return 0.

int main(void)
{
   data declarations
   statements
   return 0;
}
Previous page

Back to Lesson 2 Index
Back to Outline