Initialization of objects in C ++

I want to know, in C ++, when do objects initialize?
Is this compilation time or link time?
For example:

//file1.cpp
extern int i;
int j=5;

//file2.cpp ( link with file1.cpp)
extern j;
int i=10;  

Now, what the compiler does: for me, it allocates memory for variables.
Now I want to know:
does it add an initialization value in this repository or is it executed during the connection?

+5
source share
3 answers

Actually there are different cases:

  • ( ): init exe/dll. . ( + dll/exe )
  • : , (push/pop on x86) ( )
  • : , ( )
  • ( ): . , ( )
+2

, . , intialization , .

0

, int s. "" , , int , . , , -

0

All Articles