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 

Problem mit Templateklasse und operator+=

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





PostPosted: Thu Mar 03, 2005 12:23 pm    Post subject: Problem mit Templateklasse und operator+= Reply with quote




Hallo,

ich habe hier eine Templateklasse (CONTROLLER), der ich einen
operator spendieren wollte:

inline void operator+=(std::vector<T> & pWink {
for(int i=0; i<p.size(); i++) m_pts.push_back(p[i]);
}

Versuche ich nun, diesen Operator mit einer davon abgeleiteten Klasse
aufzurufen, sagt mir mein Kompiler:

FUNDAMENTALMATRIXDoc.cpp(57): error: no operator "+=" matches these operands
operand types are: P2DCTRL += P2DCTRL

implementiere ich nun den operator direkt in der abgeleiteten Klasse,
klappt alles:

class P2DCTRL : public CONTROLLER {
....
inline void operator+=(P2DCTRL & p) {
for(int i=0; i }

Wo liegt mein Fehler?

Tschau - Robert
--
vertrau
voraus voraus

--
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: Thu Mar 03, 2005 2:22 pm    Post subject: Re: Problem mit Templateklasse und operator+= Reply with quote



Quote:
inline void operator+=(std::vector<T> & pWink {

class P2DCTRL : public CONTROLLER<P2D
{
...
inline void operator+=(P2DCTRL & p) {
for(int i=0; i }

Wo liegt mein Fehler?

Schwer zu sagen, wenn CONTROLLER vom Typ
template< class T > class CONTROLLER: public std::vector< T > ist,
müsste es eigentlich klappen.

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
Robert W. Kuhn
Guest





PostPosted: Thu Mar 03, 2005 2:52 pm    Post subject: Re: Problem mit Templateklasse und operator+= Reply with quote



Edzard Egberts schrieb:

Quote:
inline void operator+=(std::vector<T> & pWink {

class P2DCTRL : public CONTROLLER<P2D
{
...
inline void operator+=(P2DCTRL & p) {
for(int i=0; i }

Wo liegt mein Fehler?

Schwer zu sagen, wenn CONTROLLER vom Typ
template< class T > class CONTROLLER: public std::vector< T > ist,
müsste es eigentlich klappen.

Ist er nicht:
template <typename T>
class CONTROLLER
{
....
std::vector<T> m_pts;

Aber obiges ist eine schöne Idee, die werde ich mal ausprobieren.

Tschau - Robert
--
vertrau
voraus voraus

--
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
Markus Schaaf
Guest





PostPosted: Thu Mar 03, 2005 2:55 pm    Post subject: Re: Problem mit Templateklasse und operator+= Reply with quote

"Robert W. Kuhn" <PleaseUseReplyTo (AT) gmail (DOT) com> schrieb:

Quote:
ich habe hier eine Templateklasse (CONTROLLER), der ich einen
operator spendieren wollte:

inline void operator+=(std::vector<T> & pWink {
for(int i=0; i<p.size(); i++) m_pts.push_back(p[i]);
}

Versuche ich nun, diesen Operator mit einer davon abgeleiteten Klasse
aufzurufen, sagt mir mein Kompiler:

FUNDAMENTALMATRIXDoc.cpp(57): error: no operator "+=" matches these operands
operand types are: P2DCTRL += P2DCTRL

Vermutlich ist CONTROLLER ein "abhängiger Typ" in der abgeleiteten
Klasse. Der Aufruf wird dann nur gefunden, wenn er voll qualifiert
erfolgt: »CONTROLLER
--
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





PostPosted: Thu Mar 03, 2005 4:11 pm    Post subject: Re: Problem mit Templateklasse und operator+= Reply with quote

Robert W. Kuhn wrote:

Quote:

Hallo,

ich habe hier eine Templateklasse (CONTROLLER), der ich einen
operator spendieren wollte:

inline void operator+=(std::vector<T> & pWink {
for(int i=0; i<p.size(); i++) m_pts.push_back(p[i]);
}

Versuche ich nun, diesen Operator mit einer davon abgeleiteten Klasse
aufzurufen, sagt mir mein Kompiler:

FUNDAMENTALMATRIXDoc.cpp(57): error: no operator "+=" matches these
operands
operand types are: P2DCTRL += P2DCTRL

implementiere ich nun den operator direkt in der abgeleiteten Klasse,
klappt alles:

class P2DCTRL : public CONTROLLER {
...
inline void operator+=(P2DCTRL & p) {
for(int i=0; i }

Wo liegt mein Fehler?

Dein Basisklassen-Operator nimmt einen std::vector mußt du ihm auch einen solchen übergeben, oder zumindest etwas, das in
einen konvertierbar ist. Laut Fehlermeldung hast du aber einen P2DCTRL
übergeben. Hat CONTROLLER oder P2DCTRL denn einen Konvertieroperator nach
std::vector?

--
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
Robert W. Kuhn
Guest





PostPosted: Fri Mar 04, 2005 7:15 am    Post subject: Re: Problem mit Templateklasse und operator+= Reply with quote

Rolf Magnus schrieb:

Quote:
inline void operator+=(std::vector<T> & pWink {
for(int i=0; i<p.size(); i++) m_pts.push_back(p[i]);
}
Dein Basisklassen-Operator nimmt einen std::vector mußt du ihm auch einen solchen übergeben, oder zumindest etwas, das in
einen konvertierbar ist. Laut Fehlermeldung hast du aber einen P2DCTRL
übergeben.

Aaaargh. Natürlich. Danke!

Tschau - Robert
--
vertrau
voraus voraus

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