#include <iostream>
usingnamespace std;
int main()
{
constchar* bird = "Seagul";
string name = "adam";
cout << name[1] << endl; // prints d
cout << bird << endl; // prints Seagul
cout << name << endl; // prints adam
cout << bird[3] << endl; // prints g
cout << &bird[3] << endl; // prints gul
}
so when we print out bird[3] or fourth character of the string bird, why does it only print that char and not the string starting at bird[3]
but when we pass an address to cout such as &bird[3] it prints the string starting from the address specified until it finds the null character?
And don't forget that the operators are also overloaded for std::string as well as all the standard numeric types. You can also overload these operators for your own types as well.