const有什么问题? [英] What's wrong with const?

查看:125
本文介绍了const有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++和C ++ 0x中 const 的已知缺点是什么?

What are the known shortfalls of const in C++ and C++0x?

推荐答案

我在新闻组中看到的常见投诉的两个主要问题是

The two main issues that I have seen frequent complaints about in newsgroups, are


  • 很多时间在支持非const感知的API(特别是微软的)。

  • The need to waste a lot of time on supporting non-const-aware APIs (especially Microsoft's).

需要定义方法的常量和非常量版本

我认为后者可以/应该由语言支持。

I think the latter could/should be supported by the language.

可能与协变成员函数实现,因为两者都需要一些方法来获取这个指针的类型。

Possibly in conjunction with support for covariant member function implementations, because both need some way to pick up the type of the this pointer.

第三个问题是

  • const does not propagate to owned objects.

hth。,

这篇关于const有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆