JavaScript is required

It Is legal to return local variables from a function which returns by reference.

A.

TRUE

B.

FALSE

Trả lời:

Đáp án đúng: B


Returning a local variable by reference in C++ is invalid. When a function ends, all its local variables are destroyed. Returning a reference to a local variable results in a dangling reference, pointing to invalid memory. Using this dangling reference can cause undefined behavior, including program crashes or incorrect results. Therefore, it's illegal.

Câu hỏi liên quan