代码问题?

来源:百度知道 编辑:UC知道 时间:2024/06/05 11:06:05
class RandomSting
{
public:
RandomSting(int strLen=16){
assert(strLen>0);
strLen_=strLen;
s_=new char[strLen+1];//最后一个是回车
getRandomString();
}
~RandomSting(){delete[] s_;}
上面那个class RandomSting 是什么意思?public后面为什么是冒号而不是分号?getRandomString()是什么意思?

class RandomSting //定义一个随机字符串类
{
public: //定义public方法(以下都是)
RandomSting(int strLen=16)//构造函数{
assert(strLen>0); //调用系统类的方法
strLen_=strLen;
s_=new char[strLen+1];//最后一个是回车
getRandomString(); //调用系统类的方法
}
~RandomSting(){delete[] s_;} //析构函数
C++是以对象为核心的,不像C里面以函数为核心。