Code logic question

Nov 4, 2015 at 12:59am
nm
Last edited on Nov 4, 2015 at 7:30pm
Nov 4, 2015 at 1:12am
It compiles but I'm not sure if it's correct.

I don't know how it compiles. tmp is a pointer. Line 4 is illegal if tmp is a pointer. What's with the names tmp and temp?
Nov 4, 2015 at 1:17am
nm
Last edited on Nov 4, 2015 at 7:30pm
Nov 4, 2015 at 11:54am
So you're declaring a vector called tmp, and then in the ranged for loop, you're shadowing that by declaring a pointer called tmp? Shadowing variables like that is not a good idea, because it easily leads to confusion.

What is temp?
Topic archived. No new replies allowed.