Can you show me how a c++ program can be affected by the static or the dinamic memory allocation? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you show me how a c++ program can be affected by the static or the dinamic memory allocation?

Please, tell me like I'm 5.

7th Aug 2017, 9:40 PM
Leo
Leo - avatar
3 Answers
0
just consider call by value in function(static) void swap(int x, int y) { int temp; temp = x; x = y; y = temp; return;} when you call this function there is no effect in value. dynamic memory allocation (value is changed) void swap(int *x, int *y) { int temp; temp = *x; *x = *y; *y = temp; return; }
9th Aug 2017, 11:57 AM
Siddharth K
Siddharth K - avatar
0
static (value is changed) void swap(int& x, int& y) { int temp = x; x = y; y = temp; } And in your second swap function, nothing gets dynamically allocated. ) : I believe you mixed something up. Looked like you explained pointer behaviour.
9th Aug 2017, 12:55 PM
Timon Paßlick
0
Does this help? http://www.cplusplus.com/doc/tutorial/dynamic/ Or did you already ask google?
9th Aug 2017, 1:00 PM
Timon Paßlick