gpt4 book ai didi

c++ - C++ 中的垃圾收集器

转载 作者:行者123 更新时间:2023-11-28 07:13:02 25 4
gpt4 key购买 nike

<分区>

我有一个项目,我必须用 C++ 实现垃圾收集器。现在我必须提供类图,但我不知道该怎么做。

谁能解释一下垃圾收集器是做什么的?谷歌没有帮助我!我发现很多东西都有很多类和变量。

We consider a simple language in which there are only two predefined classes, Int and Real (as in Java), allocated on 4 or 8 bytes.

  • I have declarations like int a, real b

  • assignment statements (x=y)

  • return statements (return x)

-When declaring an object, memory is allocated from a memory area corresponding dynamic allocation of proper size and free address, object's reference counter is initialized to 1

-Every assignment, increment reference count object. The same thing happens on passing values ​​present in function, as well as instructions for return

-Each time the function body ends where there is a declaration of an object, it decrements the reference counter

-When an object's reference count has reached 0, it releases the memory

我应该实现多少个类?只有 2 个预定义类......每个类都必须有一个变量“计数器”,或者有一个第 3 个类有计数器?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com