Static cast | Sololearn: Learn to code for FREE!
0

Static cast

which scenario ask us to use static cast in c++? I am looking for real life scenario rather than just the definition of the same.

12th Feb 2019, 5:20 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Answers
+ 1
I am a student at robotics, and the most i work with Arduino, which is based on C/C++ programming. When creating libraries i prefer to make my functions, methods, constants, varibles static, so when i use it i don't need to declare a variable to use these pieces. It saves a lot of memory (on UNO you have only 32KB) and is more comfortable in big projects, only use the libraryName::function(); and everything goes well. And it is the same for every C++ project when using libraries.
12th Feb 2019, 7:29 PM
Charlie S
Charlie S - avatar
+ 1
hi Charlie S , thank you for your response .. I think u answered for static memeber (data and functions) for a class.. let me try to provide a bit more detail on question.I am looking for static_cast and const_cast as well.. more concern is use of const_cast as it allows to change value of const variable declared earlier
13th Feb 2019, 2:44 AM
Ketan Lalcheta
Ketan Lalcheta - avatar