Can I use string data type only by including <iostream> library? (without #include <string>) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Can I use string data type only by including <iostream> library? (without #include <string>)

18th Oct 2016, 8:40 PM
Rebeka Asryan
Rebeka Asryan - avatar
2 Answers
+ 8
The answer is yes and no! On most of the compilers yes you can and it will work with iostream. (this includes online, linux and all GCC compilers) But, Visual studio (Microsoft compiler, I guess cl.exe) can't build that at all. You need to include string library too for sure.
18th Oct 2016, 9:13 PM
Aaron Sarkissian
Aaron Sarkissian - avatar
+ 1
This is another problem. Because with the command #include you do not include any library. But only a header file with declarations to use names from library in your code. The including of the library is made else. In IDE options of compilator. Or as parameters in command line compilators Look for it in your tools
18th Oct 2016, 11:23 PM
Petr Hatina
Petr Hatina - avatar