惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

博客园 - 后凤凰

nodejs在linux系统调用lazarus编辑的so文件 node使用koffi load dll卡死 Tencoding with out BOM lazarus配置记录 lazarus fastreport导出pdf Cant swap font ubuntu20.10安装scrcpy 背诵小鹤双拼 FireBird DataType TFDManager不能在Dll中创建线程池 cxGrid导出到图片 delphi安装package时无法定位程序输入点bpl Delphi fastreport乱码处理 electron14之后版本使用remote - 后凤凰 - 博客园 electron-edge-js编译 - 后凤凰 - 博客园 delphi 10.4.2 启动时报错 socket error go特点 elecron调用C#dll electron 14 remote使用 - 后凤凰 anbox
Delphi Records与classes几点不同
后凤凰 · 2021-10-30 · via 博客园 - 后凤凰
Though records can now share much of the functionality of classes, there are some important differences between classes and records. 
Records do not support inheritance.
Records can contain variant parts; classes cannot.
Records are value types, so they are copied on assignment, passed by value, and allocated on the stack unless they are declared globally or explicitly allocated using the New and Dispose function. Classes are reference types, so they are not copied on assignment, they are passed by reference, and they are allocated on the heap.
Records allow operator overloading on the Win32 platform; classes, however, do not allow operator overloading.
Records are constructed automatically, using a default no-argument constructor, but classes must be explicitly constructed. Because records have a default no-argument constructor, any user-defined record constructor must have one or more parameters.
Record types cannot have destructors.
Virtual methods (those specified with the virtual, dynamic, and message keywords) cannot be used in record types.
Unlike classes, record types on the Win32 platform cannot implement interfaces.

尽管reords目前可以使用许多classes的特性,但是还是有几点重要的不同

  1. records不支持继承
  2. records可以包含variant classes不能
  3. records是值类型,所以在赋值时会直接复制其值。默认在栈stack上分配存储空间,或者使用new,dispose进行分配。classes是引用类型,其赋值时传递是引用。在堆heap上分配
    1. 栈由系统内核管理
    2. 堆程序自动来分配,程序退出时,系统回收。容易造成内存泄露
  4. records在win32平台支持操作符重载
  5. records自动执行一个没有参数的构造函数进行构建。类需要显示的执行构造函数。因为record有一个默认无参的构造函数,所以用户定义的record如果构造函数,其必需有至少一个参数
  6. records不能析构
  7. records中不能使用虚方法
  8. records不能实现接口