请在下面程序的横线处填上适当内容,以使程序完整,并使运
请在下面程序的横线处填上适当内容,以使程序完整,并使运行结果为:Hello
hELLO
#include <iostream.h>
#include <string.h>
class Words
{char *str;
public:
Words(char *s)
{str=new char[strlen(s)+1];
strcpy(str,s);
}
void disp(){cout<<str<<endl;}
char operator[](int i)
{if(str[i]>='A'&&str[i]<='Z')
return char(str[i]+32);
else if(str[i]>='a'&&str[i]<='z')
return char(str[i]-32);
else
return str[i];
}
};
int main()
{int i;char *s="Hello";
Words word(s);
______________(1)____________;
for (i=0;i<strlen(s);i++)
______________(2)____________;
cout<<endl;
}答案
第1空:word.disp()
第2空:cout << word[i]