I was looking at some code and I saw this: ->. I've never seen it before. What does it mean?
Alcohol & calculus don't mix. Never drink & derive.
It's the pointer-to-member operator 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; } The last three accesses all go to the same memory location.
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; }
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You". -- Linus Torvalds
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
Java CodeBank Entries >> Parsing URL's| Collections/ShuffleElements | Threads isAlive() | Daemon Threads |Remote Class Loading | Sorted Keys (Map) | Backwards List | Thread States | Collections/Arrays Generics | Regular Expression(Grouping and Capturing) | Properties | JLabel/JTextField Combo | Reading Request Parameter Values | Host Lookup | Setting the size of a JFrames inner-region | GUI Native L&F
1. Possibly - the name works 2. Yes 3. &var takes the address of var
Forum Rules