ICP算法详解

1. static

 其中,static 成员函数没有 this 指针, non-static 成员函数有 this 指针。因此,static 成员函数只能访问 static 数据成员。

static 成员变量在类内声明,在类外定义

static 的调用方式有2种。1)通过对象调用;2)直接通过类名调用。

举例子 static 关键字的应用——把ctor放到private区

扫描二维码关注公众号,回复: 9134522 查看本文章

设计模式 Singleton 和 Meyers Singleton。后者比前者更优,原因在于,对于前者,无论是否使用 a,static A a 一直存在。对于后者,只有使用到 a,它才会被创建。

猜你喜欢

转载自www.cnblogs.com/gdut-gordon/p/11762503.html
ICP