What is the cost of sizeof?

前端 未结 7 1679
一向
一向 2021-02-05 10:06

What is the cost of sizeof?

I would expect:

  • sizeof(someclass) can be known at compile time
  • sizeof(someStaticArray) can be known at compile time
相关标签:
7条回答
  • 2021-02-05 10:49

    There is zero runtime cost. In the case of dynamically allocated memory, sizeof gives the size of the static pointer object, not the dynamically allocated memory.

    0 讨论(0)
提交回复
热议问题