Background: This is an old topic I studied multiple times, but still unfamiliar. I think most people don’t work at such a low level?
Q1: Can return a malloc object by reference? I doubt it. I think the address is lost and there’s no way to free it.
Q1b: if you only have a reference to a heap object, how can you delete it? See https://bintanvictor.wordpress.com/?p=10505&preview=true
Q: Can return a static local by reference? I think so but not popular
Q: Can return a by-ref argument by reference? No need (but legal) since the caller already has that reference. You could return it in an if/else
Q: can return another object in scope by reference? Yes
Return-by-non-const-ref is often used in operator overloading to support counter.increment()
The assignment operator returns a const ref.