PDA

Click to See Complete Forum and Search --> : What does -> mean?


Wynd
Jun 14th, 2001, 11:43 PM
I was looking at some code and I saw this: ->. I've never seen it before. What does it mean?

parksie
Jun 15th, 2001, 04:31 AM
It's the pointer-to-member operator :)
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;
}The last three accesses all go to the same memory location.

Wynd
Jun 15th, 2001, 02:55 PM
Cool, thanks.

Dillinger4
Jun 16th, 2001, 06:42 PM
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 ;)

parksie
Jun 16th, 2001, 07:33 PM
1. Possibly - the name works :)
2. Yes
3. &var takes the address of var