Path: utzoo!attcan!uunet!cs.utexas.edu!ut-emx!walt.cc.utexas.edu!petrilli From: petrilli@walt.cc.utexas.edu (Chris Petrilli) Newsgroups: comp.lang.c++ Subject: Re: #defines.... Message-ID: <33133@ut-emx.UUCP> Date: 2 Jul 90 16:00:58 GMT References: <37786@genrad.UUCP> Sender: news@ut-emx.UUCP Reply-To: petrilli@walt.cc.utexas.edu (Chris Petrilli) Organization: The University of Texas at Austin, Austin, Texas Lines: 34 In article <37786@genrad.UUCP> slp@genrad.genrad.COM (Steven L. Peters) writes: >Just out of curiousity... > >With the C++ const, enum, and inline declarations, is it ever >necessary to use #define in a C++ program? Stroustrup emphatically >says in _The C++ Programming Language_ not to use them if you don't >have to. I'm wondering if you ever have to. I can't think of a >single time where you would be forced to use a #define over const or >inline... > The only time where you HAVE to use a #define (or at least, it is the best way for clarity) is in conditionally compiled code. For example: #define DEBUG #ifdef DEBUG ... (do something) ... #endif This would be more difficult under C++ convention of using constants, than the preprocessor, since you don't care about type, just whether it is defined or not. Hope this clarifies it... if someone can thing of another time where you HAVE to use the pre-processor, I'd like to know, I might be misusing/abusing C++. + Chris Petrilli "Opinons represented here | University of Texas at Austin do not necessarily | INTERNET: petrilli@vondrake.cc.utexas.edu represent those of a sane | SNAILMAIL: 429 Brady Lane, Austin, Texas, 78746 person. Take them as + PHONE: +1 512 327 0986 simply that."