What is the use of including string library because we can use its function without including it ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the use of including string library because we can use its function without including it ?

For example ; #include <iostream > #include <string> using namespace std; int main (){ string a = 'sudip'; cout <<a.length (); return 0; } NEXT PROGRAM: #include <iostream > using namespace std; int main (){ string a = 'sudip'; cout <<a.length (); return 0; } Both programs gives output without any error.

22nd May 2021, 10:56 AM
Sudip Shrestha
Sudip Shrestha - avatar
2 Answers
+ 4
I asked the same question before https://www.sololearn.com/post/69831/?ref=app
22nd May 2021, 1:53 PM
Ipang
+ 1
The iostream library already has the string library included. It's not necessary to include <string> when <iostream> is in your code.
22nd May 2021, 11:07 AM
Sebastien Abainza
Sebastien Abainza - avatar