C++不允许将int **转换为const int **
来源:互联网 发布:装甲间隙知乎 编辑:程序博客网 时间:2024/06/16 18:26
C++ Complains about Converting 'int **' to 'const int **'
Recently when I was switching a project from C to C++, I found that C++ compilers do not allow converting int ** to const int **, even with explicit cast.
After searching on the web and thinking, I think the underlying reason is that C++ does not allow converting const T * to T *, unless const_cast is used. Let's assume that a is of type const T **, and b is of type T **. If we can assign the value of b to a, then we can make *b point to a const T variable by dereferencing a, without using const_cast. This violates the principles of C++.
One of the principles of C++ is that, if a programmer uses const_cast, he/she declares that the current conversion will do no harm to the programme; otherwise he/she may have not concerned about the possible danger brought by the current conversion, which is probably a bug. In the later case, the compiler must report an error to remind the programmer.
- C++不允许将int **转换为const int **
- C类型转换:error C2664:不能将参数 从“int”转换为“const char *”
- char int 转换不允许
- int CWnd::GetWindowTextW(LPTSTR,int) const”: 不能将参数 1 从“char [10]”转换为“LPTSTR”
- int CWnd::GetWindowTextW(LPTSTR,int) const”: 不能将参数 1 从“char [10]”转换为“LPTSTR”
- int CWnd::GetWindowTextW(LPTSTR,int) const”: 不能将参数 1 从“char [10]”转换为“LPTSTR”
- error C2664: “int CListCtrl::InsertColumn(int,LPCTSTR,int,int,int)”: 不能将参数 2 从“const char [9]”转换为“LP
- C/C++ atoi() 将字符串转换为int
- c++int转换为String
- error C2664: “int CWnd::GetWindowTextW(LPTSTR,int) const”: 不能将参数 1 从“char [15]”转换为“LPTSTR”
- error C2662: “int Fraction::numerator(void)”: 不能将“this”指针从“const Fraction”转换为“Fraction &”
- error C2664: “BOOL CDC::TextOutW(int,int,const CString &)”: 不能将参数 3 从“const char [18]”转换为“const CString &”
- error C2664: “BOOL CDC::TextOutW(int,int,const CString &)”: 不能将参数 3 从“const char [18]”转换为“const CStr
- error C2664: “BOOL CDC::TextOutW(int,int,const CString &)”: 不能将参数 3 从“const char [18]”转换为“const CStr
- 将int转换为CString的方法
- 将int转换为string类型
- SQL 将日期格式转换为Int
- 将数字字符串转换为int型
- 今天遇到一个问题,原来在html的form中如果只有一个type="text"的控件,如果在text中点击回车键,就是自动提交表单!
- 儿子的思维
- C++ 计算器小程序
- 选取 50% 的记录
- 抛弃WebService 在.NET4中用jQuery调用WCF
- C++不允许将int **转换为const int **
- 银行身份认证基本原理
- C# 线程
- CDC简介
- 关键词DISTINCT 用于返回唯一不同的值
- C#中对XML文件进行新建、查找、插入、修改、保存等操作
- Unix下配置Apache
- Microsoft DOS if command
- Qtp 11.0 如何破解?求高手回答!!