Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!fluke!dyndata!dan From: dan@dyndata.UUCP (Dan Everhart) Newsgroups: comp.lang.c++ Subject: Re: #defines.... Message-ID: <686@dyndata.UUCP> Date: 5 Jul 90 17:51:03 GMT References: <37786@genrad.UUCP> Reply-To: dan@dyndata.UUCP Organization: Dynamic Data & Electronics, Edmonds WA Lines: 35 In-reply-to: slp@genrad.uucp's message of 2 Jul 90 14:54:50 GMT In article <37786@genrad.UUCP> slp@genrad.uucp (Steven L. Peters) writes: > With the C++ const, enum, and inline declarations, is it ever > necessary to use #define in a C++ program? I don't know about *necessary* but I find it convenient to use the following: #if defined(DEBUG) #define pure { DebuggerTrap (); } #else #define pure = 0 #endif class Xyz { // ... virtual f () pure; // ... } This quickly finds erroneous calls of pure virtual functions during debugging, yet leaves no overhead in a production version. It's also highly readable. In article pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: > arguable that 'this' (which should not exist, however) should be a > reference and not a pointer, but it's too late to change that. A #define comes in handy here too: #define self (*this) I don't think you could do either of these tricks without using a #define.