• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >vc/mfc > 求教高手:在net编译通过,在vc6中智能指针出现大量的警告,帮帮我!!

求教高手:在net编译通过,在vc6中智能指针出现大量的警告,帮帮我!!

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-06-04

佚名通过本文主要向大家介绍了vc6编译器,静态编译vc6连接器,易语言vc6编译器,vc6怎么编译,vc6无法编译等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 求教高手:在net编译通过,在vc6中智能指针出现大量的警告,帮帮我!!
描述:

//
// SmartPtr -- very basic smart pointer template
//
// Provides thread-safe auto-delete for shared pointers, using
// reference counting.
//
// (c) 2003-4 Geraint Davies. Freely Redistributable.
// Destructors
//
// You can use smart_ptr/smart_array with types that are not fully defined,
// just as you can with pointers:
//      class CPointedTo;   // defined elsewhere
//      smart_ptr<CPointedTo> ptr;
//
// However the type (CPointedTo) must be fully defined when the
// destructor for the smart_ptr (ptr) is required.
// If the smart_ptr is a member of a class CYourClass, and your class has no
// explicit destructor, then the full type definition of CPointedTo is
// required at your class definition (for the default destructor). You can
// get round this by declaring an empty destructor and defining it 
// in the cpp module (where CPointedTo is fully defined).
#ifndef __SMARTPTR_H_
#define __SMARTPTR_H_
// thread-safe shared count
// -- stored separately -- the smart_ptr has a pointer
// to one of these and to the object.
class ptr_shared_count
{
public:
    ptr_shared_count()
    : m_cRef(1)
    {
    }
    void Increment()
    {
        InterlockedIncrement(&m_cRef);
    }
    bool Decrement()
    {
        return (InterlockedDecrement(&m_cRef) == 0);
    }
private:
    ptr_shared_count(const ptr_shared_count& r);
    ptr_shared_count operator=(const ptr_shared_count& r);
    long m_cRef;
};
// smart pointer. Lifetime management via reference count.
// Reference count is stored separately and each smart pointer
// has a pointer to the reference count and to the object.
// Thread safe (using InterlockedIncrement)
// 
// This version for single objects. For objects allocated with new[],
// see smart_array
template<class T> class smart_ptr
{
public:
    ~smart_ptr()
    {
        Release();
    }
    // initialisation
    smart_ptr()
    : m_pObject(NULL),
      m_pCount(NULL)
    {
    }
    smart_ptr(T* pObj)
    {
        m_pObject = pObj;
        AssignNew();
    }
    smart_ptr(const smart_ptr<T>& ptr)
    {
        m_pObject = ptr.m_pObject;
        m_pCount = ptr.m_pCount;
if (m_pCount != NULL)
{
m_pCount->Increment();
}
    }
    smart_ptr& operator=(const smart_ptr<T>& r)
    {
        Release();
        m_pObject = r.m_pObject;
        m_pCount = r.m_pCount;
        if (m_pCount != NULL)
        {
            m_pCount->Increment();
        }
        return *this;
    }
    smart_ptr& operator=(T* p)
    {
        Release();
        m_pObject = p;
        AssignNew();
        return *this;
    }
    smart_ptr& operator=(int null)
    {
        if (null != 0)
        {
            throw E_INVALIDARG;
        }
        Release();
        m_pObject = 0;
        m_pCount = NULL;
        return *this;
    }
    // access 
    T* operator->() const
    {
        return m_pObject;
    }
    T& operator*() const
    {
        return *m_pObject;
    }
    operator T*() const
    {
        return m_pObject;
    }
    // comparison
    bool operator!() const
    {
        return (m_pObject == 0);
    }
    bool operator==(int null) const
    {
        if (null != 0) {
          &nbs

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 怎么使用IHTMLDocument4,在vc6里面编译不过!
  • vc6不会自动编译自己写的idl文件?
  • insidecom的源码没有工程文件,如何用vc6编译?
  • VC6的工程,到VS2005编译后,运行错误,求解!
  • vc6编译的COM组件在VISTA或者WIN7下都是无法注册的?怎么解决?
  • 我的VC6上面midl,一编译就提示1004错误,为什么呢?
  • VC6编译程序使用signcode签名问题!
  • vc6编译失败:stdafxh预编译文件pcherrorC2859
  • vc6编译不停止,regsvr32需要终止
  • VC6中有很多编译选项,谁有文章介绍这些的谢谢

相关文章

  • 2017-06-04 (很简单的问题&&很高的分数)送分->高手。回答问题->得高分->好生活->出名->名垂青史==就是这么简单!
  • 2017-06-05 接口纯虚函数的重载问题
  • 2017-06-05 请问哪儿有进程管理软件下载
  • 2017-06-04 请教一个超级问题(关于vc7和vc6从类型库中生成的类有一些不同,如何解决?)
  • 2017-06-04 MFC中有没有这样的功能?
  • 2017-06-04 双接口,早绑定接口,晚绑定接口和自动化IDispatch,非自动化到底是什么关系?
  • 2017-06-04 求一个多线程下载的ACTIVEX,有免费的吗?
  • 2017-06-05 我现在想封装一个DLL,然后由其它开发工具调用
  • 2017-06-05 请问userthread和workerthread的区别?
  • 2017-06-05 截获ActiveX控件消息

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 线程定时器的问题
    • 数据库Outofmenory问题
    • 向VC++大虾们请教
    • 如何判断ActiveX控件的名字ID?
    • 一个多线程的程序看不明白,想请教一下
    • 关于directShow编程?如何加载一个sourcefilter?????
    • (ATL新手)如何在ATL中读/写SQLServer数据库呀?
    • ATL类库设计的问题,高手请进
    • 写word文件
    • 用COM做一个游戏控制器的属性页,系统不调用DLLGetClassObject

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有