We got practice sheets for a test next week, for studying a little bit of C++ (still a beginner here). I still can\'t figure out a simple question.
That is, why are thes
Both snippets pass a reference (or pointer in the second case) to temporary. Consider for example p(18)
. Where would 18 actually be stored? So where should p(18)
point to?
Side note: If everything would be const, the code would be ok, ie.
int const & p(int const & input) { return input; }
The standard would guarantee it.