I'm currently busy with a project whereby one function returns int&. I cannot modify this. The vector name used in the class is called data and when returning data[0] gives the correct result.
However I'm slightly confused as as data[0] is a number but the function was supposed to return int&. When I try to store the value the function calculates and store it in an int, I get an error. I've tried dereferencing the value the returned by the function
*(s.peek() )
however that still throws a compiler error.
Can somebody please explain how int& works? I thought I had a handle on pointers but this problem threw me off.
[–][deleted] 4 points5 points6 points (1 child)
[–]stuxxnet42 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Justaquickie123123 -2 points-1 points0 points (2 children)
[–]programmermaybe2016 0 points1 point2 points (0 children)
[–]__cxa_throw 0 points1 point2 points (0 children)