dimanche 31 janvier 2016

What is the diference?

I would like to understand between this two blocks of code and why the commented line leads to a crash.

int d=5;
int* b=0;
//*b=5;// this is not possible. Why?
b = &d;

and

int* b=new int;
*b=5;

Is there a way better than the other to do this? Thanks

Aucun commentaire:

Enregistrer un commentaire