seanr
seanr

Reputation: 193

Explanation of arrow and dot operator pertaining to different situations in C++

I understand the arrow operator to mean dereference a pointer to struct/object and get member for example:

int test;
test = one->two;

one being the object/struct pointer and two being the member, in this case an integer. Essentially the same as:

int test;
test = (*one).two;

However what if two was a pointer to an int? How would you retrieve the integer value stored at the address pointed to by two?

Upvotes: 0

Views: 200

Answers (1)

user3738848
user3738848

Reputation:

*((*one).two)

or

*(one->two)

Upvotes: 2

Related Questions