calling function

Go4Expert Member
31Aug2007,23:48   #1
buddy's Avatar
can a function be called without calling main( ) function??? please calrify me.. if so plz explain it in detail.
Team Leader
1Sep2007,00:18   #2
DaWei's Avatar
No. Main is called by the executive that launches the program. One should never call main explicitly. The effects of doing so result in undefined operation.
Go4Expert Founder
1Sep2007,12:09   #3
shabbir's Avatar
Quote:
Originally Posted by buddy
can a function be called without calling main( ) function??? please calrify me.. if so plz explain it in detail.
Yes a function can be called without calling the main or I would say a function can be executed before the main function is executed. Try running this program.
Code:
#include<iostream>
using namespace std;

int func()
{
	cout<<"In Func"<<endl;
	return 10;
}

static int i = func();

int main()
{
	cout<<"In Main"<<endl;
	return 0;
}