#include <iostream.h>
#include <string.h>
class Stat{
char str[101];
int n[10];
public:
Stat( char *str="" ){ strcpy(this->str, str); } //这里是什么意思?
void input();
void process();
friend ostream& operator<<(ostream&, Stat&);
};
void Stat::input()
{
cout << "input a string: ";
cin.getline( str, 100 );
}
void Stat::process()
{
unsigned int i;
for(i=0; i<10; i++) n[i] = 0;
for(i=0; i<strlen(str); i++)
if( (str[i]>='0' ) && (str[i]<='9') )
n[str[i]-'0']++ ;//这里是什么意思?
}
ostream& operator<<(ostream& ostr, Stat& st)
{
ostr << "串为:" << st.str << endl;
for( int i=0; i<10; i++)
ostr << "字符" << char('0'+i) << "的个数:" << st.n[i] << endl;
return ostr;
}
void main()
{
Stat st;
st.input();
st.process();
cout << st << endl;
帮忙读下程序,详细帮忙解释下该程序啊,谢过
}