首页 > 编程语言 > 详细

C++;一些题

时间:2016-05-03 16:20:22      阅读:223      评论:0      收藏:0      [点我收藏+]

技术分享

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

class CMyString
{
public:
    char* _str;
    CMyString()
        :_str(NULL)
    {}
     CMyString(char * str)
        :_str(new[strlen(str)+1] )
    {
        strcpy(_str,str);
    }
     CMyString(CMySting& tmp)
        :_str(new[strlen(tmp._str)+1])
    {
        strcpy(_str,tmp._str);
    }
    CMyString operator=(CMyString tmp)
    {
        swap(_str,tmp._str);
        return *this;
    }
};

技术分享(单例模式)

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

 singal::static singal* _this=NULL;
class singal
{
    char* _str;
    static singal* _this;
public:
    static singal* GetSingal()
    {
        if(_this==NULL)
            _this=getsingal();
        return _this;
    } 
private:
   singal* getsingal()
   {
       singal* tmp=new singal;
       tmp->_
   }
   singal(){}
};


C++;一些题

原文:http://shaungqiran.blog.51cto.com/10532904/1769712

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!