用例:
class A { static int s_common; public: static int getCommon () const { s_common; }; };
通常会导致以下错误:
error: static member function ‘static int A::getCommon()’ cannot have@H_502_8@ cv-qualifier
这是因为const只适用于指向该对象的对象,静态成员函数中不存在该对象.
但是如果允许,静态成员函数的“const”可能与静态数据成员很容易相关.@H_502_8@为什么C中不存在此功能?背后的任何逻辑原因?