नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
reinterpret_cast used between related classes: 'class1' and 'class2'
Remarks
Do not use reinterpret_cast to cast between related types. Use static_cast instead, or for polymorphic types, use dynamic_cast.
By default, this warning is off. For more information, see Compiler Warnings That Are Off by Default.
Example
The following code example generates C4946:
// C4946.cpp
// compile with: /W1
#pragma warning (default : 4946)
class a {
public:
a() : m(0) {}
int m;
};
class b : public virtual a {
};
class b2 : public virtual a {
};
class c : public b, public b2 {
};
int main() {
c* pC = new c;
a* pA = reinterpret_cast<a*>(pC); // C4946
// try the following line instead
// a* pA = static_cast<a*>(pC);
}