日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > c/c++ >内容正文

c/c++

C2248编译错误的原因和解决--VC6向VC7.1迁移真是累死人,N多编译错误

發(fā)布時(shí)間:2024/4/14 c/c++ 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C2248编译错误的原因和解决--VC6向VC7.1迁移真是累死人,N多编译错误 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

把以前VC6先寫好的類加入VC7中,編譯時(shí)竟然錯(cuò)誤多到編譯器無(wú)法接受而停止,hooooo.真的好煩,要是有個(gè)工具修改外加的.h和cpp文件就好了...

遇到最多的是C2248編譯錯(cuò)誤,才發(fā)現(xiàn)VC7提升了對(duì)基類成員訪問的檢測(cè)。

下面記錄一些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里是無(wú)法訪問 private typedef!(C2248)但6.0卻是可以,累了。。。
Improved accessibility checks in compiler now detect inaccessible base classes (C2248).

C2248的產(chǎn)生原因之一:從“類”創(chuàng)建的對(duì)象無(wú)法訪問該“類”的 protected private 成員。

為使代碼在 Visual C++ 的 Visual Studio?.NET 2003 和 Visual Studio?.NET 版本中都有效,使用范圍運(yùn)算符

// 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} };







如果調(diào)試器表達(dá)式引用不明確的成員名稱,必須使用類名稱來(lái)限定它。
例如,如果 CObjectCClass 實(shí)例,后者從 AClassBClass
二者中繼承了名為 expense 的成員函數(shù),則 CObject.expense 是不明確的。
可以按如下方式化解多義性:

CObject.BClass::expense

轉(zhuǎn)載于:https://www.cnblogs.com/babyblue/archive/2005/05/28/164210.html

總結(jié)

以上是生活随笔為你收集整理的C2248编译错误的原因和解决--VC6向VC7.1迁移真是累死人,N多编译错误的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。