On Thu, May 20, 1999 at 03:34:27PM +0200, Sven LUTHER wrote: > Something like > Objective Caml version 2.02 > # let id x = x ;; > val id : 'a -> 'a = <fun> > ----------------------------------- > Not sure, but i think we are not talking with the same definition of > the same word ?
C++ isn't a pure object-oriented language -- not everything is an object by any means. Nor are all classes subclasses of a single "Object" superclass, which is what you're making use of above. But yes, you can write an "id()" function which behaves differently depending on what is passed to it. Either: class foo { virtual int id() { return 1; } }; class bar : foo { virtual int id() { return 2; } }; foo f; bar b; cout << f.id(); // 1 cout << b.id(); // 2 // So yours would be: int id2(foo x) { return x.id(); } or: int id(int i) { return 1; }; int id(double d) { return 2; }; cout << id(1); // 1 cout << id(1.0); // 2 Cheers, aj, who isn't sure this is particularly relevant to debian-devel anymore. -- Anthony Towns <[EMAIL PROTECTED]> <http://azure.humbug.org.au/~aj/> I don't speak for anyone save myself. PGP encrypted mail preferred. ``There's nothing worse than people with a clue. They're always disagreeing with you.'' -- Andrew Over