• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# String and fstream question.

## Recommended Posts

If I have a code like the following:  string Name; ifstream File("file.in"); File>>Name; File>>Name;  Will the string class free the memory it used for the string after the first File>>Name, so there wont be momery leak as a result of calling one after another File>>Name?

##### Share on other sites
SiCrane    11839
If I understand your question correctly, then, yes, there should be no memory leak.

##### Share on other sites
randomZ    163
That''s one of the points of the string class (and other STL containers): They take care of their memory themselves.

---