共用方式為


編譯器警告 (層級 3) C4243

'conversion type' 轉換存在從 'type1' 到 'type2',但無法存取

備註

衍生類別的指標會轉換成基類的指標,但衍生類別會繼承具有私用或受保護存取權的基類。

Example

下列範例會產生 C4243:

// C4243.cpp
// compile with: /W3
// C4243 expected
struct B {
   int f() {
      return 0;
   }
};

struct D : private B {};
struct E : public B {};

int main() {
   // Delete the following 2 lines to resolve.
   int (D::* d)() = (int(D::*)()) &B::f;
   d;

   int (E::* e)() = (int(E::*)()) &B::f; // OK
   e;
}