C2248编译错误的原因和解决--VC6向VC7.1迁移真是累死人,N多编译错误
把以前VC6先写好的类加入VC7中,编译时竟然错误多到编译器无法接受而停止,hooooo.真的好烦,要是有个工具修改外加的.h和cpp文件就好了...
遇到最多的是C2248编译错误,才发现VC7提升了对基类成员访问的检测。
下面记录一些MSDN里提到的
VC++编译器重大修改
This topic summarizes the compile-time errors and warnings that will now be issued on code that compiled without errors or warnings in Visual Studio .NET or earlier versions.
- Closing parentheses now required for the defined preprocessor directive (C2004).
- Explicit specializations no longer find template parameters from primary template (C2146).
- A protected member (n) can only be accessed through a member function of a class (B) that inherits from the class (A) of which it (n) is a member (C2247).
- Improved accessibility checks in compiler now detect inaccessible base classes (C2248).
- An exception cannot be caught if the destructor and/or copy constructor is inaccessible (C2316).
- Default arguments on pointers to functions no longer allowed (C2383).
- A static data member cannot be initialized via derived class (C2477).
- The initialization of a typedef is not allowed by the standard and now generates a compiler error (C2513).
- bool is now a proper type (C2632).
- A UDC can now create ambiguity with overloaded operators (C2666).
- More expressions are now considered valid null pointer constants (C2668).
template<>
is now required in places where the compiler would previously imply it (C2768).- The expilicit specialization of a member function ourside the class is not valid if the function has already been explicitly specialized via a template class specialization. (C2910).
- Floating point non-type template parameters are no longer allowed (C2993).
- Class templates are not allowed as template type arguments (C3206).
- Friend function names are no longer introduced into containing namespace (C3767).
- The compiler will no longer accept extra commas in a macro (C4002).
- An object of POD type constructed with an initializer of the form () will be default-initialized (C4345).
typename
is now required if a dependent name is to be treated as a type (C4346).- Functions that were incorrectly considered template specializations are no longer considered so (C4347).
- Static data members cannot be initialized via derived class (C4356).
- A class template specialization needs to be defined before it was used in a return type (C4686).
- The compiler now reports unreachable code (C4702).
最烦人的在VC7里是无法访问 private typedef!(C2248)但6.0却是可以,累了。。。
Improved accessibility checks in compiler now detect inaccessible base classes (C2248).
C2248的产生原因之一:从“类”创建的对象无法访问该“类”的 protected 或 private 成员。
为使代码在 Visual C++ 的 Visual Studio .NET 2003 和 Visual Studio .NET 版本中都有效,使用范围运算符。
// C2248c.cpp // compile with: /LD struct A { };struct B: private A { };struct C: B {void f(){A *p1 = (A*) this; // C2248::A *p2 = (::A*) this; // OK} };
如果调试器表达式引用不明确的成员名称,必须使用类名称来限定它。
例如,如果 CObject
是 CClass
实例,后者从 AClass
和 BClass
二者中继承了名为 expense
的成员函数,则 CObject.expense
是不明确的。
可以按如下方式化解多义性:
CObject.BClass::expense
转载于:https://www.cnblogs.com/babyblue/archive/2005/05/28/164210.html
C2248编译错误的原因和解决--VC6向VC7.1迁移真是累死人,N多编译错误相关推荐
- 503 Service Temporarily Unavailable 错误可能原因及解决方法
503 Service Temporarily Unavailable 错误可能原因及解决方法 参考文章: (1)503 Service Temporarily Unavailable 错误可能原因及 ...
- Invalid bound statement (not found)错误的原因和解决办法
Invalid bound statement (not found)错误的原因和解决办法 在maven项目中有专门的resources文件夹用来存放各种配置文件,但是不一定都会放在里面,如果配置文件 ...
- 出现 java.lang.UnsupportedClassVersionError 错误的原因及解决方法
1 错误描述 正常运行程序,报出如下错误: 2 错误原因 通过观察上述标记出来的错误描述,咱们可以知道: java.lang.UnsupportedClassVersionError:Unsuppor ...
- 元空间不足java.lang.OutOfMemoryError: PermGen space 错误的原因及解决方法
出现 java.lang.OutOfMemoryError: PermGen space 错误的原因及解决方法 原因:堆内存的永久保存区内存分配不足(缺省默认为64M),导致内存溢出错误. 解决的方案 ...
- nginx产生【413 request entity too large】错误的原因与解决方法
nginx产生[413 request entity too large]错误的原因与解决方法 参考文章: (1)nginx产生[413 request entity too large]错误的原因与 ...
- 【转】error while loading shared libraries: xxx.so.x 错误的原因和解决办法
原博客地址:http://www.cnblogs.com/Anker/p/3209876.html#undefined error while loading shared libraries: xx ...
- 400错误是什么原因_499错误是什么?499错误的原因及解决方法
HTTP状态码出现499错误有多种情况,499错误是什么?下面我们来学习Nginx 499错误的原因及解决方法. 日志记录中HTTP状态码出现499错误有多种情况,比如nginx反代到一个永远打不 ...
- ORA-06413连接未打开的错误的原因和解决方法
ORA-06413连接未打开的错误的原因和解决方法 参考文章: (1)ORA-06413连接未打开的错误的原因和解决方法 (2)https://www.cnblogs.com/wybshyy/p/58 ...
- tcp连接时,BROKEN PIPE错误的原因以及解决方法
tcp连接时,BROKEN PIPE错误的原因以及解决方法 参考文章: (1)tcp连接时,BROKEN PIPE错误的原因以及解决方法 (2)https://www.cnblogs.com/ctho ...
最新文章
- SAP QM Multiple Specifications的使用II
- 昆虫大脑帮助AI解决导航难题
- Android实现富文本时遇到的一些问题(2)字体效果的保存
- 跨还是不跨?这是一个问题
- 运维组如何管理服务器资源,运维服务管理体系方案全套.doc
- Tensorflow 循环神经网络-时间序列表示
- 改善代码设计 —— 处理概括关系(Dealing with Generalization)
- java中EL表达式怎么获取网站的根目录
- 基于mybatis向oracle中插入数据的性能对比
- idea创建类时自动添加注释
- 数据结构——拓扑排序算法理解和实现
- Intel SGX开发者参考书(五)—— Intel SGX SDK示例代码(二)
- 计算机安装win10系统还原,详细教您win10怎么还原成win7
- 计算机计算建筑结构的方法有哪些,建筑结构设计包括哪些内容呢?
- [渝粤教育] 西南科技大学 会计学原理 在线考试复习资料(1)
- Python中矩阵运算中的norm范数、axis、ord参数
- 闻灾情 忆国殇 山河呜咽 寄哀思
- db2判断字符为空_DB2函数——常用函数整理
- 你的人生中,最恐惧的事情是什么
- 操作系统——分区存储管理