E
E
Evsign2014-10-27 14:21:45
C++ / C#
Evsign, 2014-10-27 14:21:45

Why do these variables need to be outside the function?

I'm reading C++ Primer by Stenli Lippman.
The section on constexpr provides such an example.
04e0f00bb6.jpg
Please explain why the variables i and j should be taken out of functions?
Although in practice everything works even if the variable i cannot be taken out.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AxisPod, 2014-10-27
@Evsign

Works, but turns into a regular const. And that's exactly what it does in the body of the function, because the actual dereference happens.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question