[gcc/qcc] Zakres dzialania static'a (?)

Q

Q

mam klase, w tej klasie mam funkcje (w sekcji private)
a w tej funkcji mam zmienna typu static;

czy jak stworze kilka obiektow tej klasy,
to wszystkie one beda wspoldzielic ta zmienna statyczna ?
 
V

Victor Bazarov

Q said:
mam klase, w tej klasie mam funkcje (w sekcji private)
a w tej funkcji mam zmienna typu static;

Translation:

I have a class. In that class I have a function (private)
and in that function I have a static variable.
czy jak stworze kilka obiektow tej klasy,
to wszystkie one beda wspoldzielic ta zmienna statyczna ?

Here my Polish is rusty... I'll try to guess. No matter how
many objects of that class exist, there is only one instance
of that static variable - inside that function. Whether you
will have a problem with that or not, depends on your intent.
If you need more than one "static" variable (one that survives
beyond the function end), make it a member variable instead.

Is that what you wanted to know?

V
 
L

lollinus

Translation:

I have a class. In that class I have a function (private)
and in that function I have a static variable.


Here my Polish is rusty... I'll try to guess. No matter how
many objects of that class exist, there is only one instance
of that static variable - inside that function. Whether you
will have a problem with that or not, depends on your intent.
If you need more than one "static" variable (one that survives
beyond the function end), make it a member variable instead.

Is that what you wanted to know?

V

Prosta odpowied¼: TAK.
Short answer: YES.
 
L

lollinus

mam klase, w tej klasie mam funkcje (w sekcji private)
a w tej funkcji mam zmienna typu static;

czy jak stworze kilka obiektow tej klasy,
to wszystkie one beda wspoldzielic ta zmienna statyczna ?

Prosta odpowied¼: TAK
Quick answer: YES
 
K

Kyle

Q napisa³(a):
mam klase, w tej klasie mam funkcje (w sekcji private)
a w tej funkcji mam zmienna typu static;

czy jak stworze kilka obiektow tej klasy,
to wszystkie one beda wspoldzielic ta zmienna statyczna ?

you may want to post to pl.comp.lang.c next time
(yes, c++ is handled there too)
 
L

lollinus

OK, we know the answer. What was the question? Thanks.

Your translation of first phrase was correct.
mam klase, w tej klasie mam funkcje (w sekcji private)
a w tej funkcji mam zmienna typu static;

Translation:

I have a class. In that class I have a function (private)
and in that function I have a static variable.

and the second is:
czy jak stworze kilka obiektow tej klasy,
to wszystkie one beda wspoldzielic ta zmienna statyczna ?

if I create couple objects of that class then all of them will share
this static variable?
 
Q

Q

you may want to post to pl.comp.lang.c next time
(yes, c++ is handled there too)

ups, it's not pl* group...
sorry for my "faux pas" and thanks for the answer :)

ps.
do I get enough sleep?
the answer is: no :)
 
Q

Q

Here my Polish is rusty... I'll try to guess. No matter how
many objects of that class exist, there is only one instance
of that static variable - inside that function. Whether you
will have a problem with that or not, depends on your intent.
If you need more than one "static" variable (one that survives
beyond the function end), make it a member variable instead.

Is that what you wanted to know?

yes and thanks for help;
/I'm surprised that anybody understand me :)

ps.
Your polish is very good :)
 
D

dertopper

OK, we know the answer.  What was the question?  Thanks.

Victor, sometimes it is better not to know the question (see the
Ultimate Question of Life, the Universe and Everything Else).

Stuart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top