引用的时候掌握一个原则:
对于要引用的单元中的全局变量, 有可能有写操作(赋值)的, 方在interface中的uses
对于要引用的单元中的全局变量, 没有写操作的, 方在implementation中的uses对于对象, 只要针对对象变量本身没有写操作的, 也应该放在implementation中.
比如:unit a;type ta=class(tobject)
public
i:integer;
end;var aa:ta;那么对于 aa.i:=10;之类的, 就只要在implementation的uses中声明一下a就可以了
而对:
aa:=ta.create; 或者:var b:ta;
b:=ta.create;
b.i:=10;
aa:=b;
之类的, 就要放在interface中声明了.其实interface个implementation中的uses有点象函数的变量声明, var=interface uses,
可以带回返回值, 而implementation uses就只能引用了.
对于要引用的单元中的全局变量, 有可能有写操作(赋值)的, 方在interface中的uses
对于要引用的单元中的全局变量, 没有写操作的, 方在implementation中的uses对于对象, 只要针对对象变量本身没有写操作的, 也应该放在implementation中.
比如:unit a;type ta=class(tobject)
public
i:integer;
end;var aa:ta;那么对于 aa.i:=10;之类的, 就只要在implementation的uses中声明一下a就可以了
而对:
aa:=ta.create; 或者:var b:ta;
b:=ta.create;
b.i:=10;
aa:=b;
之类的, 就要放在interface中声明了.其实interface个implementation中的uses有点象函数的变量声明, var=interface uses,
可以带回返回值, 而implementation uses就只能引用了.
解决方案 »
- 一道图片的缩放题目,算来算去好像都不对
- 关于一个fastreport中数据显示和打印问题
- 帮我看看 这个sql语句如何实现
- stringgrid如何使字体居中
- 能否让panel半透明,或者有能半透明的控件么
- 窗口关闭问题
- 如何用WebBrowser捕抓"该页无法显示"网页?
- 字符串问题
- 在combobox控件中加入一条记录后,怎样让其永久保存
- 有没有编码方法能让VCD文件还原成压缩以前的质量???
- select * from footordermateriel where rtrim(mano)='Ma0001' or (ordno='po02' and ordprodno='aa')
- installshied里如何获得一个路径的父目录?
(單元1)
提供给整个单元使用(單元2)
提供给implementation部分使用
(單元1)
提供给整个单元使用 (單元2)
提供给implementation部分使用