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.
2 Respostas
+ 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.
+ 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