강의

멘토링

커뮤니티

Inflearn Community Q&A

No author

This post's author information has been deleted.

[MMORPG Game Development with C++ and Unreal Series] Part 4: Game Server

Buffer Helpers

reinterpret_cast질문이있습니다.

Written on

·

365

0

template<typename T>

BufferWriter& BufferWriter::operator<<(const T& src)

{

*reinterpret_cast<T*>(&_buffer[_pos]) = src;

_pos += sizeof(T);

return *this;

}

reinterpret_cast c++강의에서 아주 강력한 변환 

포인터랑 정수사이도 변환이 가능하고.. 다 가능한 변환 느낌이었는데 앞에*를 붙여주는 이유가 궁금합니다.

*reinterpret_cast<T*>(&_buffer[_pos]) = src;

===========================

T*로 변환하는데 src가 참조라서 *를 한번 더 붙여주신건가요?

 

 

networkMMORPGwindows-server

Answer 1

1

Rookiss님의 프로필 이미지
Rookiss
Instructor

네 그렇습니다. 포인터 역참조를 할 때 *을 붙이는 것과 동일합니다.
단계별로 나눠서 쓰자면
1) T* temp = reinterpret_cast<T*>(...)
2) *temp = ...

요런 느낌이죠.

감사합니다!

No author

This post's author information has been deleted.

Ask a question