calling function

buddy's Avatar, Join Date: Aug 2007
Go4Expert Member
can a function be called without calling main( ) function??? please calrify me.. if so plz explain it in detail.
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
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.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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;
}