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 

Spezialisierung nach int

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





PostPosted: Wed Nov 05, 2003 3:46 pm    Post subject: Spezialisierung nach int Reply with quote



Hallo,

Ich habe vor eine Templateklasse nach int hin zu Spezialisieren, möchte aber
die Deklaration von der Implementierung trennen. Nun hab ich ein kleines
Syntaxproblem.
Ist das so richtig, der Compiler mag es so nicht fressen.

------------------
*CClass.h*

template<int>
class CClass{};

template<>
class CClass<1>
{
CClass();
~CClass();
[...]
};

[...weitere Spezialisierungen]

#include "CClass.cpp"
-----------------------------

*CClass.cpp*

template<>
CClass<1>::CClass()
{
[...]
}

template<>
CClass<1>::~CClass()
{

}

[...]
------------------------

Der Compiler (g++ 3.3.2) sacht mir:

CClass.cpp error: template-id `CClass<>` for `CClass<1>::CClass()` does not
match any template declaration.

Hoffe das Beispiel macht mein Problem deutlich.


MFG
Falco
--
Falco Hirschenberger <hirschen (AT) fraunhofer (DOT) de>
ICQ: 66107367

--
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
Michael Trocken
Guest





PostPosted: Thu Nov 06, 2003 7:20 am    Post subject: Re: Spezialisierung nach int Reply with quote



Falco Hirschenberger <hirschen (AT) fraunhofer (DOT) de> wrote

[...]
Quote:
Ich habe vor eine Templateklasse nach int hin zu Spezialisieren, möchte aber
die Deklaration von der Implementierung trennen. Nun hab ich ein kleines
Syntaxproblem.
Ist das so richtig, der Compiler mag es so nicht fressen.

------------------
*CClass.h*

template<int
class CClass{};

template
class CClass<1
{
CClass();
~CClass();
[...]
};

[...weitere Spezialisierungen]

Du spezialisierst mit der angegebenen Deklaration die Klasse, aber
nicht die Elementfunktionen darin. Funktionen kann man auch gar nicht
spezialisieren. Es gibt aber einen Trick:
http://groups.google.de/groups?dq=&hl=de&lr=&ie=UTF-8&oe=UTF-8&selm=bo7kh0%24ejs%2402%241%40news.t-online.com

[...]
Quote:

Der Compiler (g++ 3.3.2) sacht mir:

CClass.cpp error: template-id `CClass<>` for `CClass<1>::CClass()` does not
match any template declaration.

Da hat der Compiler auch Recht, denn für den Konstruktor von CClass
hast du kein (Funktions-)Template deklariert.


Gruß,
Michael

--
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.