#include
#include
using namespace std;
class Words
{
public:
Words(const char *w)
{
len=strlen(w);
word=new char[len+1];
strcpy(word,w);
}
~Words()
{
delete word;
}
int length() const
{
return len;
}
char& operator [](int i)
{
if(i>=0 && i
}
const char& operator [](int i) const
{
if(i>=0 && i
}
private:
int len;
char *word;
};
int main()
{
string word;
cout<<"请输入一个英文单词:";
cin>>word;
Words w1(word.c_str());
const Words w2(word.c_str());
for(int i=0;i
for(int i=0;i
//for(int i=0;i
}