“新的"和“新的"之间的区别.和"gen"表示 [英] Difference between "new" and "gen"

查看:96
本文介绍了“新的"和“新的"之间的区别.和"gen"表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在控制台和调试器中进行了一些尝试,但是我仍然对新事物和gen的工作原理存在一些疑问.

I've done a little playing around in the console and debugger, but I've still got some questions about how new and gen work differently from each other.

使用new生成结构来使用gen生成结构与使用gen生成结构之间有什么区别?

What is the difference between using new to generate a struct verse using gen to generate a struct?

"gen"是否使用现有的已分配内存,而"new"是否分配新的内存?还是两者都分配内存?

Does "gen" use existing allocated memory and "new" allocate new memory? or both allocate memory?

新"是否会生成类似于"gen"语句的所有内容?

Does "new" generate everything like a "gen" statement?

在cdnshelp中,它说新"是一个浅层结构,这意味着未分配结构字段. "gen"也是如此吗?

In cdnshelp it says "new" is a shallow struct, meaning struct fields are not allocated. Is this also true of "gen"?

推荐答案

调用new将为该结构分配内存(其他内部struct字段除外)并调用该结构的init()函数.

Calling new will allocate memory for the struct (except for other internal struct fields) and call that struct's init() function.

调用gen将完成new的所有操作,而且还会随机化该结构的字段.如果该结构的任何字段是其他结构,它也会在它们上调用gen.

Calling gen will do everything new does, but also randomize the struct's fields. If any of the struct's fields are other structs, it will call gen on them too.

这篇关于“新的"和“新的"之间的区别.和"gen"表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆