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 

konvertierung der funktionsargumente

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





PostPosted: Sun Dec 28, 2003 11:58 pm    Post subject: konvertierung der funktionsargumente Reply with quote



hallo
ich habe den untenstehenden code und er kompiliert mit der fehlermeldung
no match for `int * A<int>&' operator
unter g++ 3.2.2 nicht. wenn ich allerdings die drei auskommentierten
zeilen benutze geht es wieder.

meine frage ist daher, warum er die konvertierung von int nach A<int>
bei nicht-template-funktionen macht und bei template-funktionen nicht?

gibt es eine loesung? (ausser dem bereitstellen von allen drei
kombinationen von A<T> und T)
jan

-------------------------------------

template <typename T>
struct A {
T value_;
A (A<T> const &a) : value_ (a.value_) {}
A (T v) : value_ (v) {}
};


template <typename T>
A <T> operator * (A <T> const &a1, A <T> const &a2) {
return a1.value_ * a2.value_;
}


//A <int> operator * (A <int> const &a1, A <int> const &a2) {
// return a1.value_ * a2.value_;
//}


int main () {
A <int> a1 (5);
A <int> a2 = 5 * a1;
}

--
jan langer ... [email]jan (AT) langernetz (DOT) de[/email]
"pi ist genau drei"

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