The standard is written that this kind of type conversion is normally silent, and the real problem here is that it's not even clear what names.length() returns (signed/unsigned), it's slightly difficult to find that out (and nearly impossible if you don't already have some idea of the potential problem), and at the point in a CS1 course where you might be doing this, the students may not even know the difference between signed and unsigned!
C++ has its place in the world. Intro CS courses are not that place.