const变量初始化问题!(50分)

  • 主题发起人 主题发起人 SmallGhost
  • 开始时间 开始时间
S

SmallGhost

Unregistered / Unconfirmed
GUEST, unregistred user!
定义了一个结构:
type
TDatasourcesType = record
m_strName: string;
m_iNodeValue: integer;
end;
接下来想定义一个TDatasourcesType的数组常量,并对他进行初始化,应该怎么写呀!
const
defDatasourcesType: array[0..1] of TDatasourcesType =
(
(????),(????)
);
 
这样好像不行吧?
 
行的,以前我都用过,时间长了忘记了!
 
CONST定义的是变量吗?那VAR定义的是什么?搞笑~~~[:D]
 
说错了,应该是常量!
 
问题已经解决了!
defDatasourcesType: array[0..1] of TDatasourcesType =
(
(m_strName:'2345';m_iNodeValue:0),(m_strName:'2345';m_iNodeValue:0)
);
 
谢谢大家的参与!
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TDatasourcesType = record
m_strName: string;
m_iNodeValue: integer;
end;

TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;

const
defDatasourcesType: array[0..1] of TDatasourcesType =
(
(m_strName:'asdf';m_iNodeValue:0),
(m_strName:'asd';m_iNodeValue:1)
);

var
Form1: TForm1;

implementation

{$R *.dfm}

end.

这样编译通过了,不知道行不行?
 
多人接受答案了。
 
后退
顶部