I am wondering about this because of scope issues. For example, consider the code
typedef struct {
int x1;/*top*/
int x2;/*bottom*/
int id;
} sub
yes , the return is a copy
subline_t subline(int x1, int x2, int id) {
subline_t t = { x1, x2, id };
return t;
}
If you put a referencer, then its not a copy
subline_t & subline(int x1, int x2, int id) {
subline_t t = { x1, x2, id };
return t; // will result in corruption because returning a reference
}