c++ - Which way you prefer to send arguments? -


suppose have function:

void fun(int *a, int *b); 

which way prefer send arguments?

(1.)

int x, y; fun(&x, &y); 

(2.)

int *x, *y; fun(x, y); 

what problems other way or both same , behavior same?

usually use former if want variables on stack, , latter if allocate memory them on heap. stack typically faster, whereas heap typically bigger. in general, use first pattern quite often, , use latter when dealing giant arrays or large objects.


Comments

Popular posts from this blog

mod rewrite - Doing external redirect. .htaccess NS flag not working. How to achieve similar results? -

mysql - How to insert just year and month into date field? -