Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: For loop Pin
trønderen2-Oct-23 21:11
trønderen2-Oct-23 21:11 
GeneralRe: For loop Pin
Randor 3-Oct-23 0:08
professional Randor 3-Oct-23 0:08 
GeneralRe: For loop Pin
trønderen3-Oct-23 9:54
trønderen3-Oct-23 9:54 
GeneralRe: For loop Pin
jschell3-Oct-23 4:35
jschell3-Oct-23 4:35 
GeneralRe: For loop Pin
k505429-Sep-23 11:55
mvek505429-Sep-23 11:55 
GeneralRe: For loop Pin
Randor 29-Sep-23 12:14
professional Randor 29-Sep-23 12:14 
GeneralRe: For loop Pin
honey the codewitch3-Oct-23 12:32
mvahoney the codewitch3-Oct-23 12:32 
AnswerRe: For loop Pin
Dave Kreskowiak25-Sep-23 8:53
mveDave Kreskowiak25-Sep-23 8:53 
Calin Negru wrote:
the program will allocate memory for an int every frame.

No, it does not. An int is a "value type", and value types are usually allocated on the stack, not the heap. Also, in your example, the anint variable is only allocated (or "pushed" onto the stack once, upon execution of the loop initializer. The value in that stack location is changed on every iteration of the loop. Once the loop is complete, that variable is popped off the stack and will no longer exist.

Of course, all of this is a bit generalized and is not accurate in all cases. It is possible to allocate a value type on the heap, generally called "boxing".

GeneralRe: For loop Pin
Calin Negru25-Sep-23 22:40
Calin Negru25-Sep-23 22:40 
GeneralRe: For loop Pin
Richard Andrew x6428-Sep-23 12:12
professionalRichard Andrew x6428-Sep-23 12:12 
GeneralRe: For loop Pin
Dave Kreskowiak28-Sep-23 12:20
mveDave Kreskowiak28-Sep-23 12:20 
GeneralRe: For loop Pin
harold aptroot26-Sep-23 15:15
harold aptroot26-Sep-23 15:15 
GeneralRe: For loop Pin
Calin Negru26-Sep-23 23:09
Calin Negru26-Sep-23 23:09 
GeneralRe: For loop Pin
harold aptroot5-Oct-23 21:32
harold aptroot5-Oct-23 21:32 
QuestionService not created correctly under windows 11 but any older version. Pin
Rick R. 202323-Sep-23 14:54
Rick R. 202323-Sep-23 14:54 
AnswerRe: Service not created correctly under windows 11 but any older version. Pin
Randor 23-Sep-23 10:43
professional Randor 23-Sep-23 10:43 
GeneralRe: Service not created correctly under windows 11 but any older version. Pin
Rick R. 202323-Sep-23 12:13
Rick R. 202323-Sep-23 12:13 
GeneralRe: Service not created correctly under windows 11 but any older version. Pin
Randor 23-Sep-23 12:22
professional Randor 23-Sep-23 12:22 
GeneralRe: Service not created correctly under windows 11 but any older version. Pin
Rick R. 202323-Sep-23 12:24
Rick R. 202323-Sep-23 12:24 
GeneralRe: Service not created correctly under windows 11 but any older version. Pin
Randor 23-Sep-23 12:53
professional Randor 23-Sep-23 12:53 
GeneralRe: Service not created correctly under windows 11 but any older version. Pin
Rick R. 202323-Sep-23 13:06
Rick R. 202323-Sep-23 13:06 
QuestionRe: Service not created correctly under windows 11 but any older version. Pin
Randor 23-Sep-23 15:57
professional Randor 23-Sep-23 15:57 
AnswerRe: Service not created correctly under windows 11 but any older version. Pin
Rick R. 202324-Sep-23 6:37
Rick R. 202324-Sep-23 6:37 
GeneralRe: Service not created correctly under windows 11 but any older version. Pin
Randor 24-Sep-23 7:08
professional Randor 24-Sep-23 7:08 
Questionfingerprint sensor code with c++ Pin
ibiere21-Sep-23 23:56
ibiere21-Sep-23 23:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.