码迷,mamicode.com
首页 > 其他好文 > 详细

修饰符(整数篇)

时间:2017-02-11 16:48:34      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:nts   classes   com   alt   send   技术   size   button   nap   

unit Unit4;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm4 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}

procedure integer1(a: Integer);
begin
  a := a + 1;
end;

procedure integer2(const a: Integer);
begin
  //什么都不做
  a.ToString;
end;

procedure integer3(var a: Integer);
begin
  a := a + 1;
end;

procedure integer4(out a: Integer);
begin
  a := a + 1;
end;

procedure Int641(a: Int64);
begin
  a := a + 1;
end;

procedure Int642(const a: Int64);
begin
  //什么都不做
  a.ToString;
end;

procedure Int643(var a: Int64);
begin
  a := a + 1;
end;

procedure Int644(out a: Int64);
begin
  a := a + 1;
end;

procedure TForm4.Button1Click(Sender: TObject);
var
  i: Integer;
  i2: Int64;
begin
  i := 10;
  i2 := 10;
  Integer1(i);
  Memo1.Lines.Add(i.ToString);
end;

end.

 

首先Integer1---无修饰符

技术分享

 

技术分享

 

 技术分享

 

=========================================================================

 integer2---const

技术分享

 

技术分享

 

 

=========================================================================

 integer3---var

技术分享

 

 技术分享

 

技术分享

 

 

=========================================================================

 integer4---out

技术分享

 

 

技术分享

 

 经过测试 int64也是如此。

结论:整型 是传值的,就是说 所有的整型要么值复制一份入栈,要么直接用原来的值,与堆无关。

修饰符(整数篇)

标签:nts   classes   com   alt   send   技术   size   button   nap   

原文地址:http://www.cnblogs.com/del88/p/6389306.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!