sorry for my ignorance
when is the constructor of a global object called??
at startup of the program?
and if there are more threads it is called by the first thread ?
sorry for my ignorance
when is the constructor of a global object called??
at startup of the program?
and if there are more threads it is called by the first thread ?
It's called sometime before main(), I think.
I don't see how you could get it to run in a different thread.
It is called just before main() starts - in the same thread that will start main [at least that is the case in all OS's I'm familiar with].
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
More precisely, it will be called before the user code of main() is executed. On some implementations, if you examine the stack trace of these initialization, main() may actually be in there, because the standard is written such that it is allowed for an implementation to insert the initialization code at the start of main().
(Specifically, that's why the standard disallows calling main() - on such an implementation, the initialization would be repeated.)
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
thank you!