Boolan微专业-面向对象高级编程学习笔记(Week02)

2018-01-15  本文已影响0人  GoMomi

Class with pointer member(stirng)

1. Big Three

构造函数和析构函数

拷贝构造

拷贝赋值


2. Stack(栈) 与 Heap(堆)

Stack

Heap

其他内存块 [参考]

对象


3. new & delete

new 与 构造

delete 与 析构

内存详情

Single Object

Array Object

Array New 一定要搭配 Array Delete

4. Static

Static Data Member

Static Function Member

Singleton(单例) [参考] --- 把 ctor 放在 private 区

class Singleton {
  public:
    static Singleton& Instance() {
    static Singleton theSingleton;
      return theSingleton;
  }

/* more (non-static) functions here */

private:
  Singleton();                            // ctor hidden
  Singleton(Singleton const&);            // copy ctor hidden
  Singleton& operator=(Singleton const&); // assign op. hidden
  ~Singleton();                           // dtor hidden
};

概念辨析

上一篇下一篇

猜你喜欢

热点阅读