11/4string

#include <iostream>
 
using namespace std;
class my_string
{
private:
    char *str;
    int len;
public:
    my_string(){}//无参构造
    my_string(char* s,int l):str(s),len(l){}//有参构造
    my_string(my_string& s1){}//拷贝构造
    my_string& operator=(my_string& s1){}//拷贝赋值函数
    bool my_empty();//判空
    int my_size();//长度
    char* my_str();//转化为c风格字符串
};
 
bool my_string::my_empty()
{
    if(len==0)
    {
        cout<<"enpty:"<<true<<endl;
        return true;
    }
    else
    {
        cout<<"empty:"<<false<<endl;
        return false;
    }
}
char* my_string::my_str()
{
 
}
int my_string::my_size()
{
    cout<<"len:"<<len<<endl;
    return len;
}
int main()
{
    char* a = "abcde";
    //cout<<a<<endl;
    int b=0;
    while(1)
    {
        b++;
        if(a[b]=='\0')
        {
            break;
        }
    }
    my_string s1(a,b);
    s1.my_empty();
    s1.my_size();
 
    my_string s2(s1);
    my_string s3;
    s3 = s2;
   // cout<<b<<endl;
 
    return 0;
}
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值