Pointers vs References
As I already mentioned, you can add to the pointer any number you want to go to the next storage unit. For example:
123456int a = 1; int *pa = &a; cout << pa << endl; pa++; cout << pa;
Pay attention that we moved forward to 4 bytes (size of the int type). Such math operation is unavailable for references:
123456int a = 1; int &ra = a; cout << ra << endl; ra++; cout << ra;
We changed the value of the variable a but not the reference.
Obrigado pelo seu feedback!
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Pergunte-me perguntas sobre este assunto
Resumir este capítulo
Mostrar exemplos do mundo real
Awesome!
Completion rate improved to 2.94
Pointers vs References
Deslize para mostrar o menu
As I already mentioned, you can add to the pointer any number you want to go to the next storage unit. For example:
123456int a = 1; int *pa = &a; cout << pa << endl; pa++; cout << pa;
Pay attention that we moved forward to 4 bytes (size of the int type). Such math operation is unavailable for references:
123456int a = 1; int &ra = a; cout << ra << endl; ra++; cout << ra;
We changed the value of the variable a but not the reference.
Obrigado pelo seu feedback!