Warning C26466
Don't use
static_cast
downcasts. A cast from a polymorphic type should use dynamic_cast.
See also
Example
struct Base {
virtual ~Base();
};
struct Derived : Base {};
void bad(Base* pb)
{
Derived* test = static_cast<Derived*>(pb); // C26466
}
void good(Base* pb)
{
if (Derived* pd = dynamic_cast<Derived*>(pb))
{
// ... do something with Derived*
}
else
{
// ... do something with Base*
}
}
Feedback
https://aka.ms/ContentUserFeedback.
În curând: Pe parcursul anului 2024, vom elimina treptat Probleme legate de GitHub ca mecanism de feedback pentru conținut și îl vom înlocui cu un nou sistem de feedback. Pentru mai multe informații, consultați:Trimiteți și vizualizați feedback pentru