I am trying to compile this code on different IDEs. I am using some string functions and string operations which need the inclusion of . But surprisingly this code doesn't give any error and shows the expected output without including . I have been taught to include whenever i need to use string methods and operations. I verified the outputs on Code::Blocks and ideone.com. They do the same and compile without any error. How is this possible?
#include<iostream>
using namespace std;
int main()
{
string str1="Hello";
string str2="School";
string str3;
cout<<str1<<"\n";
str3=str1+str2;
cout<<str3<<"\n";
int x=str3.find(str1);
cout<<x;
}
Output:
Hello
HelloSchool
0
Aucun commentaire:
Enregistrer un commentaire