This commit is contained in:
xliu79
2020-07-19 10:38:38 +08:00
parent 9f6088a31e
commit 2bdeea85d1
129 changed files with 5264 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
/**
* @file static_error.cpp
* @brief 静态函数不可以声明为虚函数同时也不能被const和volatile关键字修饰!
* 原因如下:
* static成员函数不属于任何类对象或类实例所以即使给此函数加上virutal也是没有任何意义
* 虚函数依靠vptr和vtable来处理。vptr是一个指针在类的构造函数中创建生成并且只能用this指针来访问它静态成员函数没有this指针所以无法访问vptr。
* @author 光城
* @version v1
* @date 2019-07-24
*/
virtual static void fun() { }
static void fun() const { }