C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

error: too few template-parameter-lists

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Dirk Jagdmann
Guest





PostPosted: Tue Sep 07, 2004 10:37 am    Post subject: error: too few template-parameter-lists Reply with quote



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





PostPosted: Tue Sep 07, 2004 12:09 pm    Post subject: Re: error: too few template-parameter-lists Reply with quote



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





PostPosted: Tue Sep 07, 2004 12:32 pm    Post subject: Re: error: too few template-parameter-lists Reply with quote



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





PostPosted: Tue Sep 07, 2004 1:01 pm    Post subject: Re: error: too few template-parameter-lists Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.