@Necip
No need to use new and delete, STL containers implicitly store their data on the heap. delete can cause problems: if an exception is thrown, delete is never reached, neither is the destructor.
Ok, got rid of the namespace (hard habit to break for me sometimes), added some further examples to facilitate my understanding. Sort of mystified that sometimes a ' will trigger an error where a " reconciles it, and sometimes the opposite occurs. For me it has been trial and error in these limited cases.
#include<iostream>
#include<string>
void PrintString(const std::string &string_h)
{
std::cout<<"Index [3] of long sentence ="<<string_h[3];
std::cout<<std::endl;
char d = 't';
int index = string_h.find(d);
std::cout<<"character "<<d<<" found at index "<<index<<" of: "<<string_h<<std::endl;
std::cout<<"Non-symbolic (magical number)"<<std::endl;
index = string_h.find('s');
std::cout<<"character "<<'s'<<" found at index "<<index<<" of: "<<string_h<<std::endl;
}
int main()
{
std::string string_h;
string_h= "red";
char d = 'r';
int index = string_h.find(d);
std::cout<<"character "<<d<<" found at index "<<index<<" of: "<<string_h<<std::endl;
std::cout<<"To function:"<<std::endl;
string_h = "long sentence";
PrintString(string_h);
return 0;
}