In C++, a static member function of a class cannot be virtual.

  For example, below program gives compilation error.

 1 #include<iostream>
2 using namespace std;
3
4 class Test
5 {
6 public:
7 // Error: Virtual member functions cannot be static
8 virtual static void fun()
9 {
10 }
11 };

  

  Also, static member function cannot be const and volatile.

  Following code also fails in compilation.

 1 #include<iostream>
2
3 using namespace std;
4
5 class Test
6 {
7 public:
8 // Error: Static member function cannot be const
9 static void fun() const
10 {
11 }
12 };

  Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

  转载请注明:http://www.cnblogs.com/iloveyouforever/

  2013-11-26  20:31:21

最新文章

  1. 限制Xamarin获取图片的大小
  2. liunx打开指定端口
  3. ReactiveCocoa中信号的使用
  4. 根据List中对象的某一属性进行排序
  5. 常用 CSS 中文字体 Unicode 编码表
  6. JSF 2.0 hello world example
  7. THINKPHP 5.0目录结构
  8. MySQL主从复制的配置
  9. ArcGIS地图打印那些事
  10. Java 领域从传统行业向互联网转型你必须知道的事儿
  11. js优化 前端小白适用
  12. Hibernate入门(二)——hibernateAPI详解
  13. Apache与Nginx动静分离
  14. [转] mongoose学习笔记(超详细)
  15. Nodejs----单点登录
  16. vuex 知识点
  17. collectd+influxdb+grafana
  18. 使用uwsgi发布项目
  19. lightoj 1205 数位dp
  20. Makefile--基本规则(零)

热门文章

  1. Java操作MongoDB之mongodb-driver(一)
  2. Git使用教程之初级入门命令行(二)
  3. 多线程 | 03 | CAS机制
  4. celery tasks always in pending
  5. dotnet templating 定制自己的项目模板
  6. 《Python语言程序设计》【第3周】基本数据类型
  7. scrapy_电影天堂多页数据和图片下载
  8. Excel 读取写入数据库
  9. js 开始
  10. vue+node+mongondb实战之mongodb登陆操作