For example:
int a = 5;
int &b = a;
++b;
b and a are both 6
Greetings
For example:
int a = 5;
int &b = a;
++b;
b and a are both 6
Greetings
Use a const pointer, e.g.,
Code:int a = 5; int *const b = &a; ++(*b);
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
C does not have references and probably never will. It's that kind of language.
But fret not, it has and always will have pointers which can do everything references can and more, albeit in a slightly more complicated way.
Heh, they(pointers) could be a headache if stuff like this was abused:
Heh, ptr is also validCode:int value = 5; int *foo = &value; int **bar = &foo; int ***baz = &bar // Or how about int ******ptr; printf("%d",***baz);
But for the sake of being on topic, as Elysia has already said, C has pointers and pass by value. No pass by reference like in C++