E2363 Attempting to return a reference to local variable 'identifier' (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Compiler Errors And Warnings (C++) Index

This C++ function returns a reference type, and you are trying to return a reference to a local (auto) variable.

This is illegal, because the variable referred to disappears when the function exits.

You can return a reference to any static or global variable, or you can change the function to return a value instead.