HP SunSoft Pascal 4.0 Uživatelský manuál Strana 95

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 333
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 94
Program Construction and Management 71
4
In a real program, header.h would probably contain many declarations and
would be included in several modules. Aside from routine declarations,
header files often contain constant, type, and variable declarations.
Sharing Variables Between Units
Variables that are global across a unit (that is, not declared locally in a routine)
can be public or private. A public variable can be shared by any unit that
is linked to the unit that declares the variable. A private variable cannot be
shared.
You can use the public and private reserved words to declare that a var
section declares public or private variables. For example:
When you do not use public or private, variables are public by default.
However, when you compile with the -xl option, variables are private by
default.
To share a public variable, simply declare it in each unit where you want to
share it. As long as the variable is public, each reference to that variable
accesses the same data.
program program_unit3 (output);
public var
x : integer;
private var
y : integer;
Zobrazit stránku 94
1 2 ... 90 91 92 93 94 95 96 97 98 99 100 ... 332 333

Komentáře k této Příručce

Žádné komentáře