Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Don't use
static_castdowncasts. 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*
}
}