I am learning C++ language. I would like to know what the advantages of static_cast are. Because similar types are use in C type cast also. Can anybody solve this confusion? Any help would be highly appreciated.
I am learning C++ language. I would like to know what the advantages of static_cast are. Because similar types are use in C type cast also. Can anybody solve this confusion? Any help would be highly appreciated.
Using static_cast method you can convert type int to a char. But it has one disadvantage the resulting char does not have enough size to hold the entire value. It is very simple to use static_cast over, but you also ensure that static_cast not at all do a run time check and for this reason sometimes error are anonymous. There for use dynamic_cast instead of static_cast.
There are lots of advantages of static_cast over using c type cast but I have given sone of it.try to understand it.
1. When you use static_cast method, then you are telling the user what you actually wanted to do.
2. When you do not do daft things then compiler tells you that you have to perform daft things before proceeding.
Bookmarks