zoukankan      html  css  js  c++  java
  • c++

    c++ 11
    std::ref 引用 头文件#include <functional>
    std::cref const引用
    std::move right ref
    std::decay 类型转换
    std::bind
    std::bind1st
    std::make_shared
    std::tuple 多个值的pair集合
    c++ 17
    std::any
    std::variant 代表的是一个结构体
    std::optional 代表可为空

    c++ 内存 模型
    B 继承 A
    构造: 先A 后B
    析构: 先B 后A
    e.g.
    #include <string>
    #include <iostream>

    using namespace std;
    class A
    {
    public:
    A() { cout << "A constructor" << endl; }
    virtual ~A() { cout << "A DeConstructor" << endl; }
    };
    class B : public A
    {
    public:
    B() :A() { cout << "B constructor" << endl; }
    ~B() { cout << "B DeConstructor" << endl; }
    };

    int main(int argc, char** argv)
    {
    //必须使用多态的方式,析构函数是否为virtual 才会析构
    A* a = new B();
    delete a;
    B b;

    return 0;
    }

    环形引用:
    shaderdptr,在最后一个加weakptr
    weakptr:
    sharedptr的实现:
    void AddRef(){
    ref* = new ref;
    }
    weakptr:
    Aptr B
    APtr C
    tmp_ptr B和C互换

    enable_shared_from_this:
    在同一个类中需要传递shared_ptr时候需要继承,
    这里boost库和stl都对此实现

  • 相关阅读:
    ubuntu系统上常用的开发工具
    wamp环境下安装pear
    PHP中preg_match_all函数用法使用详解
    晚睡对策
    iphone相关
    090213 阴
    月曜日の予定(10:30までREVIEW  10:00まで完成予定)
    一个通知
    我还没走
    星期5
  • 原文地址:https://www.cnblogs.com/yang131/p/13857654.html
Copyright © 2011-2022 走看看