struct
objects are always copied by value, not by reference. This means that when your struct
is returned via an accessor method, that returned object is a copy of the one in your object instance. I suspect this comes from C where it makes no difference in the scenario of a standalone function that also shares that return type:
struct sample
{
int arr[4];
};
struct sample FunctionThatReturnsSample(void)
{
static struct sample s = { { 0, 1, 2, 3 } };
return s;
}
int main(void)
{
FunctionThatReturnsSample().arr[3] = 4;
printf("%d\n", FunctionThatReturnsSample().arr[3]);
// still prints "3"
}