why does the execution of a c++ program start with main()???
Answer Posted / rajesh paul
Actually this is a very obvious question from our curiosity...
Even I was also very much puzzled at one time with this question and after a long time of discussion with my frnds and some books I got it clear. The explanation is as follows--
consider the code segment given by Brian--
class MyStatic
{
public:
MyStatic() { cout << "MyStatic Class called." << endl; };
};
static MyStatic ms;
void main()
{
cout << "main called." << endl;
}
Output : =
MyStatic Class called.
main called.
---------------X---------------
This happens because at run-time the static members are loaded into the RAM automatically along with the main() function. Hence as the class 'MyStatic' is statically instantiated before main(), the constructor function is called before main() as because the object is static i.e. already loaded into RAM hence the constructor is executed. Thereafter the main() is executed.
So from this discussion we come to the conclusion that "It is OS that instructs the system loader to load the main() into RAM automatically at run-time but no other function is loaded into RAM until and unless the main() calls them". That's what I want to say...........................
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
write a program to convert a decimal number in to its equivalent binary number?
How connect plc and pc through software
Is stl part of c++ standard?
totoo po ba ang manga aliens!
how can u do connectivity in c++ language? plz send me connectivity code in c++ ?
Who wrote stl?
draw a flowchart that accepts two numbers and checks if the first is divisible by the second.
Define stl.
What is the stl, standard template library?
please visit this site you'll find my question this is my homework please answer it if you can http://easyscience.org/ib/lofiversion/index.php/t36168.html
To modify an, existing worksheet. What steps are involved for: 1. Inserting and deleting rows and columns. 2. Printing cell formulas 3Jld displayed values 3. Using the page setup command
How is stl different from c++ standard library?
sir please send me bpcl previous question papers
What does stl stand for in basketball?
How stl is different from the c++ standard library?