Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Type.2: Don't use static_cast downcasts. Use dynamic_cast instead." only works for polymorphic objects #270

Closed
mgehre opened this issue Oct 2, 2015 · 2 comments
Assignees

Comments

@mgehre
Copy link

mgehre commented Oct 2, 2015

If the object is not polymorphic, then dynamic_cast cannot replace static_cast. This should be explicitly mentioned in the rule.

@hsutter
Copy link
Contributor

hsutter commented Oct 5, 2015

Bjarne will add wording to cover this. Part of the answer is that if it's not polymorphic you shouldn't be using static_cast either.

@BjarneStroustrup
Copy link
Contributor

added an example and explanation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@mgehre @hsutter @BjarneStroustrup @gdr-at-ms and others