I am able to initialize a string on codechef ide without using header file but the iostream hedaer file. How?
The following code runs.
:— # include< iostream>
int main()
{
string p;
return 0;
}
I am able to initialize a string on codechef ide without using header file but the iostream hedaer file. How?
The following code runs.
:— # include< iostream>
int main()
{
string p;
return 0;
}
You might wanna read here [Why does omission of “#include ” only sometimes cause compilation failures?][1]
Read the comments of accepted answer as well.
In short your above code might compile, reason is simply that you have included other standard headers which also happen to include string.
For instance if you remove the first line of iostream, it will no longer compile. So it is a good practice to include header files.
[1]: https://stackoverflow.com/questions/9539650/why-does-omission-of-include-string-only-sometimes-cause-compilation-failur