NOTE:
These are a little sketchy...I'll fill in details 'soon'.
ostream & operator<<(ostream & out,
const String & other) // friend?
{
return out << other.string;
}
ostream & operator<<(ostream & out,
const String & other) // friend?
{
return out << ((other.string==nullptr)?(""):(other.string));
}
ostream & operator<<(ostream & out,
const String & other) // friend?
{
long i, wide, shorter;
if (other.length > 0)
{
wide = out.width(0);
if (wide != 0)
{
shorter = min(wide,other.length);
if (((out.flags() & ios::adjustfield) != ios::left) &&
(shorter < wide))
{
out << setw(wide-shorter) << "";
}
for (i = 0; i < shorter; i++)
{
out << other.string[i];
}
if (((out.flags() & ios::adjustfield) == ios::left) &&
(shorter < wide))
{
out << setw(wide-shorter) << "";
}
}
else
{
out << other.string;
}
}
return out;
}
char String::operator[](long index)
{
return string[index];
}
char String::operator[](long index)
{
return (index < length) ? (string[index]) : (EOS);
}
char String::operator[](long index)
{
return ((index >= 0) && (index < length))
? (string[index])
: (EOS);
}
String x;
cout << x[i];
String x;
x[i] = 'a';
char & String::operator[](long index)
{
return ((index >= 0) && (index < length))
? (string[index])
: (EOS);
}
char & String::operator[](long index)
{
static char error;
error = EOS;
return ((index >= 0) && (index < length))
? (string[index])
: (error);
}
void fnc(const String & arg)
{
...arg[i]...
}
char & String::operator[](long index) const
{
static char error;
error = EOS;
return ((index >= 0) && (index < length))
? (string[index])
: (error);
}
char & String::operator[](long index)
{
static char error;
error = EOS;
return ((index >= 0) && (index < length))
? (string[index])
: (error);
}
char String::operator[](long index) const
{
return ((index >= 0) && (index < length))
? (string[index])
: (EOS);
}