How does sizeof work? How can I write my own?

后端 未结 10 2525
粉色の甜心
粉色の甜心 2021-02-08 07:29

I know C++ and know the function sizeof itself but I need to write my own sizeof function so please explain how it works exactly? What does it do with the parameter

10条回答
  •  广开言路
    2021-02-08 08:20

    sizeof is a compiler built-in operator. It is evaluated at compile-time by the compiler, and there is no runtime code behind it. You cannot write your own.

    Asking this is akin to asking how you would write your own version of return.

提交回复
热议问题