Prime Sieve function doubt

In the the primeSieve() , we are returning a vector primes which has been declared inside the function , which means it would have been given memory on the stack frame . So after the function got over and the vector is returned , how are we able to access the vector in main() ? IS it that vector is allocated memory on heap?

actually a copy of vector is being passed, and not the address.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.