定义一个类,成员变量是String数组s,成员方法有s的setter和getter,显示s中使用字符串元素的方法。

如题所述

第1个回答  2009-10-09
java :
class TestString{
String s[] ;
public TestString(int length){
s=new String [lenth];
}

private void setter(){

}
private void getter(){

}

private void dispS(){
if(s==null){
System.out.println("s is null ! ");
}else{
for(int i=0 ;i<s.length;++i)
System.out.println(this.s[i]);
}
}
}

c++:

#include <string>
#include <iostream>
using namespace std ;

const int LENGTH =10 ;
class str {
public: str (){

}
~str(){

}
void setter (){

}

void getter(){

}

void dispStr(){
for (int i =0 ;i <LENGTH;i++){
cout<< s[i]<<endl;
}
}
private :string s [LENGTH] ;

};
int main(){

}本回答被网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网