在块中定义变量? [英] Defining variables in a block?

查看:74
本文介绍了在块中定义变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在一个块中定义一个变量,以使

在该块之外不可见?例如,在CI中可以写出


{

int a

....

}


然后只能在curley括号内使用


在Pascal中有''Begin / End''


tnx

解决方案




LucioH写道:

是否有可能在一个块中定义一个变量,以使它在该块之外不可见?例如,在CI中可以写出





然后一个只能在curley括号

在Pascal中有''开始/结束''




没有*完全*像{}或开始/结束我可以考虑到;但是你可以使用任何现有的块结构来模拟这种纯粹的语法块:




....

循环直到真


如果为真那么

....

结束如果


带新物件

....

结束时

-

Larry Lard

回复团体请


(回复自我) )


Larry Lard写道:

LucioH写道:

是否可以在块中定义变量以便制作它在那块外面看不见?例如,在CI中可以写出





然后一个只能在curley括号

在Pascal中有''开始/结束''
没有*完全*像{}或开始/结束我能想到的;但是你可以使用任何现有的块结构来模拟这种纯粹的语法块:


...
Loop Until True

如果真的那么
...
结束如果

使用新对象
...
结束




比上面的更好(我认为这不会起作用,但

确实如此),这避免了创建一个对象: br />

什么都没有

....

结束



> -
Larry Lard
回复团体




Lucio,


块尺寸值/对象中的A在块外总是不可见


我希望这会有所帮助,


Cor

Is it possible to define a variable in a block in order to make
it invisible outside that block? For example, in C I can write

{
int a
....
}

then a will only be available inside the curley brackets

In Pascal there is ''Begin/End''

tnx

解决方案



LucioH wrote:

Is it possible to define a variable in a block in order to make
it invisible outside that block? For example, in C I can write

{
int a
...
}

then a will only be available inside the curley brackets

In Pascal there is ''Begin/End''



Nothing *exactly* like { } or Begin/End I can think of; however you can
use any of the existing block constructs to simulate this sort of
purely syntactic block:

Do
....
Loop Until True

If True Then
....
End If

With New Object
....
End With
--
Larry Lard
Replies to group please


(replying to self)

Larry Lard wrote:

LucioH wrote:

Is it possible to define a variable in a block in order to make
it invisible outside that block? For example, in C I can write

{
int a
...
}

then a will only be available inside the curley brackets

In Pascal there is ''Begin/End''
Nothing *exactly* like { } or Begin/End I can think of; however you can
use any of the existing block constructs to simulate this sort of
purely syntactic block:

Do
...
Loop Until True

If True Then
...
End If

With New Object
...
End With



Better than the above is this (which I didn''t think would work, but
does), which avoids creating an object:

With Nothing
....
End With



--
Larry Lard
Replies to group please




Lucio,

A in a block dimensioned value/object is always invisible outside a block

I hope this helps,

Cor


这篇关于在块中定义变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆