This commit is contained in:
Light-City
2019-11-05 16:56:07 +08:00
parent 3a495d7fa2
commit 8edbbbc5a2
179 changed files with 428 additions and 26 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 { }