Why can't a static member function have a cv-qualifier?
answer :
Firstly, 'cv' means const and volatile(opposite to const)
When you apply the const qualifier to a non-static member function, it affects the this pointer. [ Note: A static member function does not have a this pointer (9.3.2). —end note ]For a const-qualified member function of class C, the this pointer is of type C const*, whereas for a member function that is not const-qualified, the this pointer is of type C*.
A static member function shall not be virtual. There shall not be a static and a non-static member function with the same name and the same parameter types.
A static member function shall not be declared const, volatile, or const volatile.
静态成员函数特性解析
本文解释了为什么静态成员函数不能拥有cv限定符。探讨了cv限定符的意义,并说明了其如何影响非静态成员函数的this指针类型。此外,文章还强调了静态成员函数不能声明为const、volatile或const volatile。
128

被折叠的 条评论
为什么被折叠?



