⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 refcount.cpp

📁 压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架>>所有源码
💻 CPP
字号:
#include "refcount.h"//startMyString::MyString(const MyString& str) : m_Impl(str.m_Impl) {    m_Impl -> m_RefCount++;    cout << m_Impl->m_Chars << "::refcount: " << m_Impl->m_RefCount << endl;}MyString::~MyString() {    cout << m_Impl->m_Chars << "::refcount: " << m_Impl->m_RefCount << endl;    if (--m_Impl -> m_RefCount == 0) {        cout << m_Impl->m_Chars << "::memory released" << endl;        delete m_Impl;    }}void MyString::operator=(const MyString& str) {    if (str.m_Impl != m_Impl) {        if (--m_Impl -> m_RefCount == 0)            delete m_Impl;        m_Impl = str.m_Impl;   /* Just copy the address. */        ++(m_Impl->m_RefCount);    }}//endvoid  MyString::display() const {    cout << m_Impl -> m_Chars;}int MyString::length() const {    return m_Impl->m_Len;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -