tags:

views:

150

answers:

2

Is it possible to call global methods from within a class where they are obscured by member functions of the same name?

I know in C++ you have the following syntax:

int var = 0;

void temp() {
    int var = 2;
    ::var = var;
} //Global var is set to 2
+5  A: 

You can try

UnitName.VarName := 2
DiGi
+10  A: 

Yes you can by using the name of the unit instead of ::

Like:

unit1.var := 2;

See for more details: http://delphi.about.com/od/beginners/l/aa060899.htm

AlexV
Thanks that's exactly what I needed
JPvdMerwe
This is why I take issue with the use of the term "Global" in Delphi/Pascal. i.e. not Global variables, but Unit variables. If correct terminology were used then the answers to such questions would be more obvious. i.e. not "how do I refer to a global variable?", but "How do I refer to a unit variable?". The fact that "Uses" brings Unit symbols into scope is not sufficient reason to misuse the meaning of "Global" in a language that technically has no such concept (and the fact that the official help/documentation mis-uses the term too is no excuse either).
Deltics