 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dirk Jagdmann Guest
|
Posted: Tue Sep 07, 2004 10:37 am Post subject: error: too few template-parameter-lists |
|
|
Hallo,
Da gibt es auch nach Jahren fröhlichen Programmierens in C++ immer noch
Überraschungen. Ich wollte gerade eine Klasse schreiben und schaffe es
nicht eine statische Klassenvariable zu definieren. Mein Problem ist,
dass ich leider die Fehlermeldung nicht recht verstehe, will heißen, mir
ist leider überhaupt nicht klar, warum der Compiler hier nicht weiterkommt.
----------
template <typename T>
class Bla {
private:
static int staticData;
public:
Bla() { staticData=0; }
};
int Bla<char>::staticData; // dies ist nicht korrekt
int main() {
Bla<char> b;
return 0;
}
----------
Darauf meldet mir mein g++ 3.4.1 "temp.cpp:8: error: too few
template-parameter-lists"
Ist es vielleicht gar nicht möglich in einer template Klasse statische
Variablen zu benutzen? Wenn ja, wie sieht die korrekte Zeile 8 aus?
--
---> doj / cubic
----> http://cubic.org/~doj
-----> http://llg.cubic.org
--
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 |
|
 |
Falk Tannhäuser Guest
|
Posted: Tue Sep 07, 2004 12:09 pm Post subject: Re: error: too few template-parameter-lists |
|
|
Dirk Jagdmann wrote:
| Quote: | ----------
template <typename T
class Bla {
private:
static int staticData;
public:
Bla() { staticData=0; }
};
int Bla
|
template <typename T>
int Bla<T>::staticData = 42 * sizeof(T); // Initialisierung, falls gewünscht
MfG
Falk
--
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 |
|
 |
Olaf Krzikalla Guest
|
Posted: Tue Sep 07, 2004 12:32 pm Post subject: Re: error: too few template-parameter-lists |
|
|
Hi,
| Quote: | Darauf meldet mir mein g++ 3.4.1 "temp.cpp:8: error: too few
template-parameter-lists"
Also fehlt eine Template-Parameter-Liste. In Deinem Fall ist die zwar |
leer, muß aber trotzdem angegeben werden.
template<>
int Bla<char>::staticData;
sollte es tun.
Hth
Olaf Krzikalla
--
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 |
|
 |
Dirk Jagdmann Guest
|
Posted: Tue Sep 07, 2004 1:01 pm Post subject: Re: error: too few template-parameter-lists |
|
|
| Quote: | template <typename T
int Bla
gewünscht
|
danke, so gehts.
--
---> doj / cubic
----> http://cubic.org/~doj
-----> http://llg.cubic.org
--
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 |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|