Struct field access
Is the return value of someStruct.someField a copy of the field? If I get
a pointer to that value, will the pointer point to the value in the struct
or a copied value on the stack?
e.g. Is the following guaranteed(it appears to work in a simple test) to
work?
struct SomeStruct {
int someField;
SomeStruct() : someField(0) {}
}
void func(int* val) {
*val = SOME_OTHER_INT_VALUE;
}
SomeStruct someStruct;
func(&(someStruct.someField));
// Is it guaranteed that someStruct.someField == SOME_OTHER_INT_VALUE?
No comments:
Post a Comment