C ++ study notes eleventh class type conversion keyword

Study Notes content from: Ditai Software College Tangzuo Lin teacher's video, I appreciate your guidance

1.static_cast:

(1) for conversion between the base type
(2) can not be used for conversion between the base type pointer
(3) for converting conversion between the inheritance relationship between classes of objects and classes pointer

2.const_cast

(1) for removing the read-only attribute variable
target casts (2) must be a pointer or reference

3.reinterpret_cast

(1) cast between a pointer type
(2) for forced switching between pointer and an integer type

4.dynamic_cast

(1) for switching between class inheritance relationship pointer
(2) for switching between class pointer cross relationship
(3) has a function of checking the type
(4) required to support a virtual function
(5) Conversion unsuccessful null pointer is returned

Published 14 original articles · won praise 0 · Views 98

Guess you like

Origin blog.csdn.net/u012321968/article/details/104450305