| View previous topic :: View next topic |
| Author |
Message |
Daniel Schüle Guest
|
Posted: Thu May 20, 2004 3:51 pm Post subject: static frage |
|
|
Hallo NG
im globalen namespace
static class foo
{/**/}bar;
macht variable bar static
was ist eigentlich wenn
static class foo
{/**/};
foo bar; // ist bar static oder ist die obige defintion so falsch?
oder so
typedef static class foo foo_t;
foo_t bar; // ist hier bar static?
man könnte ja noch const/volatile ins Spiel bringen
die Frage bleibt die selbe, und zwar auf was bezieht sich dann der modifier
auf den typ oder auf die variable (wenn diese der Klassendefinition folgt)?
MfG
Daniel
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Horst Kraemer Guest
|
Posted: Thu May 20, 2004 7:27 pm Post subject: Re: static frage |
|
|
On Thu, 20 May 2004 17:51:58 +0200, Daniel Schüle
<uval (AT) rz (DOT) uni-karlsruhe.de> wrote:
| Quote: | static class foo
{/**/}bar;
|
Definiert eine statische Variable namens bar vom Typ class foo.
| Quote: | macht variable bar static
was ist eigentlich wenn
static class foo
{/**/};
foo bar; // ist bar static oder ist die obige defintion so falsch?
|
Sie ist falsch, 'static' ist kein zulaessiges Attribut einer Klasse,
sondern ein Attribut einer Variablen. Damit beantworten sich auch die
uebrigen Fragen.
typedef static int sint;
geht auch nicht ;-)
--
Horst
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Rolf Magnus Guest
|
Posted: Fri May 21, 2004 9:26 am Post subject: Re: static frage |
|
|
Daniel Schüle wrote:
| Quote: | Hallo NG
im globalen namespace
static class foo
{/**/}bar;
macht variable bar static
|
Genau.
| Quote: | was ist eigentlich wenn
static class foo
{/**/};
foo bar; // ist bar static oder ist die obige defintion so
falsch?
|
Ersteres. Nur Variablen und Funktionen können static sein, Klassen
nicht.
| Quote: | oder so
typedef static class foo foo_t;
foo_t bar; // ist hier bar static?
man könnte ja noch const/volatile ins Spiel bringen
die Frage bleibt die selbe, und zwar auf was bezieht sich dann der
modifier auf den typ oder auf die variable (wenn diese der
Klassendefinition folgt)?
|
Immer auf die Variable, da sie auf den Typ gar nicht angewendet werden
dürfen.
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Rolf Magnus Guest
|
Posted: Fri May 21, 2004 11:32 am Post subject: Re: static frage |
|
|
Rolf Magnus wrote:
| Quote: | was ist eigentlich wenn
static class foo
{/**/};
foo bar; // ist bar static oder ist die obige defintion so
falsch?
Ersteres.
|
Das ist natürlich Quatsch. Es hätte "Letzteres." heißen müssen.
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
|