Hello everybody,
I'm hatem faheem a student in Cairo university , Faculty of Engineering , Computer departement
I have a question in the C++ string class constructor <string>
that's the code
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s0 ("Initial");
string s1 (s0,3);
string s2 ("Initial",3)
cout<<"s1 : "<<s1<<"\n";
cout<<"s2 : "<<s2<<"\n";
return 0;
}
After excution we will find that
* s1 : tial
* s2 : Ini
which means that s1 was initialized by s0 starting from index 3
but s2 was intialized by first 3 caharcters from s0
what's the diffrence ?????
and why they aren't same ????
Thanks,