`
Poechant
  • 浏览: 212093 次
博客专栏
Bebe66e7-3a30-3fc9-aeea-cfa3b474b591
Nginx高性能Web服务...
浏览量:23494
5738817b-23a1-3a32-86de-632d7da73b1e
Cumulus实时媒体服务...
浏览量:21402
社区版块
存档分类
最新评论

C++ Programming Error/Warning Analysis (1) cannot have cv-qualifier

 
阅读更多

C++ Programming Error/Warning Analysis (1) cannot have cv-qualifier

  • Author:柳大·Poechant(钟超)
  • Email:zhongchao.ustc#gmail.com (# -> @)
  • Blog:Blog.CSDN.net/Poechant
  • Date:May 9th, 2012

Explanation

不能有 CV 限定符,在 C++ 中 CV 限定符指constvolatile

  • 非成员函数

在 C++ 中,普通函数(非类的成员函数)不能有 CV 限定,即constvolatile限定。即非类的成员行数,用const进行修饰:

int test() const //这是不对的,普通函数(非成员函数不能有CV约束)
{
    //实现
}
  • 静态函数

在 C++ 中,静态成员函数(static成员函数)不能有 CV 限定,即constvolatile限定。即类的静态成员函数,也不能有 CV 约束:

class Test
{
public:
    static int test_fun() const;                 //这个是不允许的。
}

Reference

  1. http://blog.163.com/xychenbaihu@yeah/blog/static/132229655201149281131/

-

柳大·Poechant:Blog.CSDN.net/Poechant

-

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics