Why we use string library while using string data type?

According to book from which I am learning C++, you should add string library before using string data type, but suddenly when I missed adding string library the program was still working fine why?
( https://i.imgsafe.org/2bb7b68.png )

1
2
3
4
5
6
7
8
9
10
11
12
13

#include <iostream>
#include <string>
using namespace std;
int main()
{
 string day = "Monday";
 
 cout << day << " Go to school\n";
 
 return 0;
}


and also working without string library:-

1
2
3
4
5
6
7
8
9
10
11
12

#include <iostream>
using namespace std;
int main()
{
 string day = "Monday";
 
 cout << day << " Go to school\n";
 
 return 0;
}


So, why we write a additional line if program is working fine without it, or it is doing something else that I am missing to know?
Last edited on
http://www.cplusplus.com/forum/general/4202/

Edit: Might I add that both my and @cire's link can be found with a simple google search.
Last edited on
Topic archived. No new replies allowed.