Can some one explain in detail why this program behaves the way it does. I mean , static/const objects would have been allocated space in data segment at compile time , then why constructor is getting called during run before main ? What goes in background for this ?
-Manish On Jun 30, 1:00 am, Varma <[email protected]> wrote: > Hi All, > Is there any way to call our function before main() is called ? > > I know there is a way in C++ as below , but Is there a standard way > in C ? > > #include <iostream.h> > class CStatic > { > public: > CStatic() { cout << "Before Main!" << endl; } > ~CStatic() { cout << "After Main!" << endl; } > > }; > > CStatic cs; > int main() > { > cout << "Begin Main" << endl; > cout << "Doing something" << endl; > cout << "End Main" << endl; > > } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
