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.
3 Réponses
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; }
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.
0
Does this help?
http://www.cplusplus.com/doc/tutorial/dynamic/
Or did you already ask google?