变量未初始化是什么意思啊(10分)

H

herozzl

Unregistered / Unconfirmed
GUEST, unregistred user!
编译时出现变量未初始化是什么意思啊
[Warning] Main.pas(472): Variable 'pbmp' might not have been initialized
[Warning] Main.pas(536): Variable 'circleradius' might not have been initialized
 
在程序可能的执行流程中,某一个流程用到的变量'pbmp'在这个流程前的值是不确定的
例如
function a():integer;
begin
if **** then exit;
Result:=3;
end;
这里就可能会出现可能没有返回值的编译警告
 
楼上正解,补充说明一下:
function a():integer;
var
pbmp: Integer;
begin
if pbmp=3 then //这里pbmp3没赋值就直接使用了。
begin
...
end;
Result:=3;
end;
 
你给它一个初始值就好了
 
如果是一个数值型那就是没有赋值
如果是一个类那就是没有构造(一般create)
 
这个对程序的稳定运行有影响吗?
 
影响很大哦。就像一个判断一样
if i<3 then
dothings
这里如果i是程序内的临时变量,则是一个随机数
如果是全局变量,则是你以前赋的值或者0;
建议找一本 书从头看起;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
477
import
I
I
回复
0
查看
818
import
I
顶部