简单c++单例模式实现-创新互联

#include#include#include#includeclass Process{
public:
    Process(){
        ps = NULL;
    };
    virtual ~Process(){};
    static Process *getinstance(){
        if(ps == NULL)
            ps = new(std::nothrow)Process();
        return ps;
    };
protected:
    int newPicPath[10];
    void playnpic(){
        for(int i=0;i<10;i++){
            printf("%d ",newPicPath[i]);
        }printf("\n");
    };
    static void* playPic(void *){
        if(ps != NULL){
            ps->playnpic();
        }
    };
private:
    static Process *ps;
};

class te_process : public Process{
public:
    te_process(){};
    ~te_process(){};
    void func(){
        pthread_t tid;
        pthread_create(&tid,NULL,playPic,this);
    };
};

int main()
{
    int i;
    te_process *te = new(std::nothrow)te_process();
    for(i=0; i<10; i++){
        te->getinstance()->newPicPath[i] = i;
    }
    te->func();
    return 0;
}

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧

在大竹等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站建设、做网站 网站设计制作按需定制设计,公司网站建设,企业网站建设,成都品牌网站建设,网络营销推广,成都外贸网站建设公司,大竹网站建设费用合理。

分享题目:简单c++单例模式实现-创新互联
文章网址:https://www.cdcxhl.com/article6/joeog.html

成都网站建设公司_创新互联,为您提供网页设计公司网站营销网站建设移动网站建设服务器托管电子商务

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都定制网站网页设计