본문 바로가기
C++

reinterpret_cast 정리

by juheeL 2016. 12. 14.

서버에서 보낸 패킷을 클라에서 받을 때 reinterpret_cast로 패킷을 변환하더라.



reinterpret_cast 설명



타입이니 뭐니 하는 것을 따지지 않고 무조건적으로 변환해버린다. (reinterpret 다시 해석하다, 새로 해석하다) 대단히 위험한 방법으로, 안전하다는 보장이 없다.)

 

만능~

 

일반 변수와 포인터 변수간의 대입은 누가 봐도 비정상적인데, reinterpre_cast 쓰면 된다. 데이터 손실 상관 안한다.

 

Reinterpret_cast : 데이터를 비트 단위로 그대로 때려넣는다!

                     

 

Reinterpret_cast 단점 : 무척 안전하지 않다.

 




 

출처 http://genesis8.tistory.com/107