On Thu, 30 Dec 2004 23:15:18 +0100 (CET), Patrick Percot <ppercot@xxxxxxx> wrote > On Thu, 30 Dec 2004 11:47:19 -0500, Christian Convey <conveycj@xxxxxxxxxxxxxxxxx> wrote > > > Hello, > > Hi, > > > > > I'm trying to write a small library of function templates, all named > > "toString", that will produce a string rendition of various data types. > > > > My problem is that when I try to create a specialized version of the > > toString() function for a particular data type, I get an error: > > > > Don't you think that operator overloading is a better and more elegant > solution ? > Mmh, and I forgot to remove the template : #include <iostream> #include <sstream> #include <vector> #include <string> using namespace std; class Foo { private: int x; int y; public: Foo(int xv, int yv) : x(xv) , y(yv) {}; friend ostream& operator<< (ostream& os, const Foo& f); }; ostream& operator<< (ostream& os, const Foo& f) { os << "(" << &f << ") = Foo(" << f.x << ", " << f.y << ")"; } int main() { Foo f(1,2); cout << f << endl; } [..Zappé 50 lignes et 918 caractères..] À+ PP -- NE MANGEZ PAS DE FOIE GRAS : http://www.stopgavage.com Groupe Morbihannais d'Utilisateurs de Logiciels Libres http://www.tuxbihan.org GPG fingerprint = 1A4F E154 3D2C A20E E4CA A543 7951 C5C2 E44A A0B5 Patrick Percot.