?? 10_85.cpp
字號:
#include<iostream.h>
#include<string.h>
class words
{
int len;
char *str;
public:
int getlen(){return len;}
words(char *s)
{
str=new char[strlen(s)+1];
strcpy(str,s);
len=strlen(s);
}
~words(){delete str;}
char operator [](int n)
{
static char ch; //聲名空字符
if(n>len-1)
{
cout<<"數組下標越界!";
return ch;
}
else
return *(str+n);
}
void disp(){cout<<str<<endl;}
};
void main()
{
words word("Time devours all things!");
word.disp();
cout<<"此語句字符數共為:"<<word.getlen()<<endl;
for(int i=0;i<25;i++)
cout<<word[i]<<" ";
cout<<endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -