Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!brunix!sdm From: sdm@cs.brown.edu (Scott Meyers) Newsgroups: comp.lang.c++ Subject: Printing pointers using operator<< Message-ID: <8165@brunix.UUCP> Date: 8 Jun 89 06:30:34 GMT Sender: news@brunix.UUCP Reply-To: sdm@cs.brown.edu (Scott Meyers) Organization: Brown University Department of Computer Science Lines: 21 I want to overload operator<< so that I can print the value of a pointer (in hex). This is what I've tried: ostream& operator<<(ostream& s, void *ptr) { return s << hex(unsigned(ptr)); } My goal is to have this function be called for a variable of type T* iff there is no operator<< function that takes a T* as an argument. g++ 1.35 compiles this without complaint, but cfront 1.2 says: error: << defined both as operator <<() and ostream::operator <<() I looked in to find a conflicting definition of operator<< that takes a void* as an argument, but I failed to find one. Other experiments I performed convince me that cfront doesn't consider void* to be an "exact match" for a T*. If someone could explain what is happening, I'd appreciate it. Scott sdm@cs.brown.edu