Can we execute a program without entering into main( ) function?

Here is a program which ends before execution of main( ) function starts but still manages to get the output.

Basically all global objects are created before entering into main(); So you can write any code into the constructor of objects, which will be called whenever object is created.

class A

{

public :

A( )

{

cout << “In A” ;

exit( 1 ) ;

}

} ;

main( )

{

cout << “not reached” ;

}

A a ;

Subscribe / Share

It's very calm over here, why not leave a comment?

Leave a Reply




Categories

Powered by Yahoo! Answers