I was looking at some code and I saw this: ->. I've never seen it before. What does it mean?
Printable View
I was looking at some code and I saw this: ->. I've never seen it before. What does it mean?
It's the pointer-to-member operator :)
The last three accesses all go to the same memory location.Code:struct mystruct {
int x;
char y;
long z;
};
void somecode() {
mystruct thingie;
mystruct *ptr = &thingie;
int num;
num = ptr->x;
num = (*ptr).x;
num = thingie.x;
}
Cool, thanks.
Hey parksie. I havent coded in C++ in ages. A couple of questions.....
1.) Is the -> operator called the indirect member access operator?
2.) Is what you are doing with the -> called dereferencing?
3.)And what is the use of & with "&thingie;"?
just curiouus.........
Us Java programmers forget this stuff ;)
1. Possibly - the name works :)
2. Yes
3. &var takes the address of var