Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!apollo!mrst!sdti!turner From: turner@sdti.SDTI.COM (Prescott K. Turner) Newsgroups: comp.lang.c++ Subject: Re: const in C++ vs. const in C Summary: usable in constant expressions Keywords: const Message-ID: <463@sdti.SDTI.COM> Date: 22 Jun 89 14:24:00 GMT References: <2742@ssc-vax.UUCP> Reply-To: turner@sdti.UUCP (0006-Prescott K. Turner, Jr.) Organization: Software Development Technologies, Sudbury MA Lines: 20 In article <2742@ssc-vax.UUCP> dmg@ssc-vax.UUCP (David Geary) writes: > > I've heard before that const is better supported in C++ >than in C. Is this true? If so, why? It's because in C++ you can define a name to be const and it is then usable in contexts which require a constant. For example, const int size = 5; int a[size]; Also if you don't take the address of the const object, cfront can optimize its storage out of existence. In order for this to be easy to use, declaring something const implies that it has internal linkage. So it can be initialized in a header file making its value is available to every module which needs it. -- Prescott K. Turner, Jr. Software Development Technologies, Inc. P.O. Box 366, Sudbury, MA 01776 USA (508) 443-5779 UUCP: ...{harvard,mit-eddie}!sdti!turner Internet: turner@sdti.sdti.com