asp源码网站,网站设计与网页制作招聘,wordpress谷歌字体加载慢,理财公司网站模板下载const修饰的函数:
表示在该函数体内不能修改成员的值#xff0c;会在函数中添加一个隐式的参数const this*.
static修饰的函数没有this指针#xff0c;与const的用法冲突。
但可以使用static和const修饰成员。
例子如下#xff1a;
class Singleton
{
public:
stati…const修饰的函数:
表示在该函数体内不能修改成员的值会在函数中添加一个隐式的参数const this*.
static修饰的函数没有this指针与const的用法冲突。
但可以使用static和const修饰成员。
例子如下
class Singleton
{
public:
static const Singleton* getInstance()
{
return instance;
} Singleton(const Singleton src) delete;
Singleton operator(const Singleton src) delete; private:
Singleton() {}
static const Singleton* instance;
};
const Singleton* Singleton::instance new Singleton;