Can a file be associated with multiple stream objects?
I read in a book that it is a runtime error to attempt to open a file that is already opened (associating another stream object with the same file). To test this, I made the following code: https://code.sololearn.com/ctyASnbmtR2t/#cpp When I ran the code, no runtime errors occurred, but I couldn't explain the reason for the output. Why is it different in the two cases? Why wasn't even a single "Hello\n" printed when the streams weren't tied? And why wasn't two "World\n"'s printed in the second case? Why does the 3rd way work just as intended? Also, does this now mean that multiple streams can point to the same file? Also, is this a form of undefined behavior? If yes, then is the book taking these operations as errors because they have undefined behavior?