21.02.2015 Views

Pola i metody statyczne

Pola i metody statyczne

Pola i metody statyczne

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Zmienne <strong>statyczne</strong><br />

1<br />

#include <br />

void FunkcjaZPamiecia( )<br />

{<br />

static int IloscWywolan = 0;<br />

}<br />

printf(”Wywolanie nr: %i\n”,++IloscWywolan);<br />

int main( )<br />

{<br />

printf(”Wartosc poczatkowa: %i\n”,<br />

FunkcjaZPamiecia( );<br />

FunkcjaZPamiecia( );<br />

FunkcjaZPamiecia( );<br />

return 0;<br />

}<br />

IloscWywolan);<br />

❤❤❤❤❤❤❤❤❤<br />

✭✭✭✭✭✭✭✭✭<br />

Wynik działania programu (po usunięciu<br />

pierwszej instrukcji):<br />

Wywolanie nr: 1<br />

Wywolanie nr: 2<br />

Wywolanie nr: 3<br />

Zmienne <strong>statyczne</strong> w języku C pełnia˛<br />

rolę zmiennych globalnych z ograniczonym zakresem dostępu<br />

tylko do poziomu funkcji, w której sa˛<br />

deklarowane.<br />

<strong>Pola</strong> i <strong>metody</strong> <strong>statyczne</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!