Question 20
Back to Exercise
Which return type gives callers read-only, no-copy access to a private std::vector<double>?
- A std::vector<double>
- B std::span<const double> Correct
- C double*
- D std::vector<double>&
Correct Answer: Option B
A span of const elements is a view: iteration and reading are allowed, modification is not. const std::vector<double>& also works.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!