void error(char* p)
{
cout ‹‹ p ‹‹ "\n";
exit(1);
}
char& string::operator[](int i)
{
if (i‹0 || strlen(p-›s)‹i) error("index out of range");
return p-›s[i];
}
main()
{
string x[100];
int n;
cout ‹‹ "here we go\n";
for (n = 0; cin››x[n]; n++) {
string y;
if (n==100) error("too many strings");
cout ‹‹ (y = x[n]);
if (y=="done") break;
}
cout ‹‹ "here we go back again\n";
for (int i=n-1; 0‹=i; i--) cout ‹‹ x[i];
}
b7_2_8.cxx
#include ‹stream.hxx›
struct employee {
friend class manager;
employee* next;
char* name;