同志们,谁知道这个参数的意思(50分)

  • 主题发起人 主题发起人 myliu
  • 开始时间 开始时间
M

myliu

Unregistered / Unconfirmed
GUEST, unregistred user!
Procedure aprocedure(out Obj);
begin
end;

上述代码可以编译通过,但是怎么解释obj这个参数??
欢迎高手指点
 
Out是Com中的输出类型。
应该隐含为Variant变量吧。
 
?没见过。
 
我想应该是Untyped Parameter
但是不知道怎么使用
 
在线等待中....
 
out表示只有输出值,但不接受输入值。
你可以传入一个值,但是过程不会用到
你的输入值。
obj无类型定义,表示可以接受任何类型
的输入,无类型数据在使用前必须先用
强制类型转换转成适当的类型。
 
An out parameter, like a variable parameter, is passed by reference. With an out parameter, however, the initial value of the referenced variable is discarded by the routine it is passed to. The out parameter is for output only
that is, it tells the function or procedure where to store output, but doesn抰 provide any input.
For example, consider the procedure heading

procedure GetInfo(out Info: SomeRecordType);

When you call GetInfo, you must pass it a variable of type SomeRecordType:

var MyRecord: SomeRecordType;

...
GetInfo(MyRecord);

But you抮e not using MyRecord to pass any data to the GetInfo procedure
MyRecord is just a container where you want GetInfo to store the information it generates. The call to GetInfo immediately frees the memory used by MyRecord, before program control passes to the procedure.
 
免费加菜:
这是在服务和客户编程中使用的一种参数概念。
在这类编程中,参数的传递有大致几种类型:
1.由一方发到另一方,不再返回。
2.由一方发到另一方,另一方处理后再发回。
3.双方相互发送和返回。
你的问题就是其中的第二种。Delphi 中使用 in 表示第一种类型的传递参数,
用 out 表示第二种类型的传递参数,第三种,就是常见的 var 了。
Delphi 中有多种参数传递的表示,比如用 var 的参数传递,表示是:任何对参数的
修改都会改变参数的原始值,如果不加 var 声明传递参数,原始值是不会改变的。
in 的表示就是一个普通的单向传参,怎么都不会改变原始值。out 类似于 var 的单向
传参。等等,等等...
 
各位大虾:
还是不大明白怎么使用,可否给一个详细的例子,比如怎么赋值,怎么接受回传的
参数之类的,
没有例子也可以,给几行简单的代码也可。
 
上面都说清楚了,out和var赋值使用方法是一样的,
除了一点:你传入的参数没有用。


 
多人接受答案了。
 
后退
顶部