Xref: utzoo comp.lang.c++:4264 gnu.g++:322 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!milano!hsinchu!knutson From: knutson@hsinchu.sw.mcc.com (Jim Knutson) Newsgroups: comp.lang.c++,gnu.g++ Subject: What's the diff? Message-ID: <2731@hsinchu.sw.mcc.com> Date: 4 Aug 89 03:32:05 GMT Organization: MCC, Austin, TX Lines: 31 What's the difference between the ++ operator overload functions in these two examples? The Lippman book (p. 197) prefers to define the function type to return a reference to the class while the Pohl book (p. 125) seems to prefer to return the class. Both seem to work equally well as both lvalue and rvalue. class counter { int count; public: counter() { count = 0; } counter(int c) { count = c; } counter& operator ++() { count++; return *this; } value() { return count; } }; class counter { int count; public: counter() { count = 0; } counter(int c) { count = c; } counter operator ++() { count++; return *this; } value() { return count; } }; Jim Knutson knutson@mcc.com cs.utexas.edu!milano!knutson -- Jim Knutson knutson@mcc.com cs.utexas.edu!milano!knutson