Why is sizeof(std::string) only eight bytes?

后端 未结 2 1443
暗喜
暗喜 2020-11-28 12:39

Why is std::string\'s size, as determined by sizeof(std::string), yield 8?
I thought it should be more than 8 as it h

2条回答
  •  攒了一身酷
    2020-11-28 12:59

    Because all your implementation of std::string stores is a pointer to the heap where all of it's data is stored.

提交回复
热议问题