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 

Statisches Element in Template Klasse

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





PostPosted: Tue Oct 05, 2004 11:49 am    Post subject: Statisches Element in Template Klasse Reply with quote



Hallo,
ich denke, dass statische Klassenelemente von Templateklassen für jede
Ausprägung eine eigene Instanz dieses Elements anlegen!
Kann man das umgehen?

Babak

--
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
Edzard Egberts
Guest





PostPosted: Tue Oct 05, 2004 12:16 pm    Post subject: Re: Statisches Element in Template Klasse Reply with quote




Quote:
ich denke, dass statische Klassenelemente von Templateklassen für jede
Ausprägung eine eigene Instanz dieses Elements anlegen!

Sieh an, hört sich sinnvoll an.

Quote:
Kann man das umgehen?

Das statische Element (als statisches Element) in eine eigene Klasse
stecken?

Gruß,

Ed

--
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 Karcher
Guest





PostPosted: Tue Oct 05, 2004 4:14 pm    Post subject: Re: Statisches Element in Template Klasse Reply with quote



Edzard Egberts <Ed_03 (AT) t-online (DOT) de> wrote:
Quote:
ich denke, dass statische Klassenelemente von Templateklassen für jede
Ausprägung eine eigene Instanz dieses Elements anlegen!
Kann man das umgehen?
Das statische Element (als statisches Element) in eine eigene Klasse
stecken?

Am besten, Du nimmst diese eigene Klasse als öffentliche Basisklasse:

#include <ostream>
#include <iostream>
#include <string>

class CommonSubobject {
static std::string name = "TollesTemplate";
};

template<typename T>
class TollesTemplate : public CommonSubobject {
/* */
};

int main(void)
{
std::cout << TollesTemplate std::cout << TollesTemplate }

In diesem Programm sind TollesTemplate TollesTemplate<char*>::name as gleiche statische Objekt, nämlich
CommonSubobject::name.

Michael Karcher

--
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
M. Hrabowski
Guest





PostPosted: Tue Oct 05, 2004 6:41 pm    Post subject: Re: Statisches Element in Template Klasse Reply with quote

Eine virtuelle Basisklasse benutzen, die das static member enthält, von der
die template Klasse ableitet.

Quote:
Hallo,
ich denke, dass statische Klassenelemente von Templateklassen für jede
Ausprägung eine eigene Instanz dieses Elements anlegen!
Kann man das umgehen?

Babak


--
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
Daniel Albuschat
Guest





PostPosted: Wed Oct 06, 2004 9:34 am    Post subject: Re: Statisches Element in Template Klasse Reply with quote

M. Hrabowski wrote:
Quote:
Eine virtuelle Basisklasse benutzen, die das static member enthält, von der
die template Klasse ableitet.

Ob virtuell oder nicht, sollte dem OP ueberlassen bleiben...
fuer dieses Problem hat es auf jeden Fall keine Relevanz.

MfG,
Daniel Albuschat

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