From 445f8ac27ea4978acf30830e68756a922d7c9e6c Mon Sep 17 00:00:00 2001 From: whoandrewis <40810386+whoandrewis@users.noreply.github.com> Date: Thu, 7 Feb 2019 07:15:33 -0800 Subject: [PATCH] Added ex C style Cast - important to recognize (#27371) Additional note on how C-style casts are not recommended. Important for people to recognize when they come across, and modify if they wish. --- guide/english/cplusplus/casting/index.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/guide/english/cplusplus/casting/index.md b/guide/english/cplusplus/casting/index.md index 7316dcc3a1..223290f732 100644 --- a/guide/english/cplusplus/casting/index.md +++ b/guide/english/cplusplus/casting/index.md @@ -70,13 +70,21 @@ void staticCastTest(float floatVal) { std::cout << intVal << std::endl; } +//not recommended but important to recognize +void cStyleCastTest(float floatVal) { + // Convert the float into a double. + auto doubleVal = (double)(floatVal); + std::cout << doubleVal << std::endl; +} + int main() { MyClassChild myClass; reinterpretCastTest(&myClass); constCastTest(myClass); dynamicCastTest(&myClass); staticCastTest(10.5); - + cStyleCastTest(11.9); + return 0; } ```