Article View: comp.std.c++
Article #2200Re: Can I declare private constants?
From: brianmcg
Date: Sun, 15 Oct 1995 14:39
Date: Sun, 15 Oct 1995 14:39
21 lines
1309 bytes
1309 bytes
> However, there is a neat little workaround. You can initialize the const
> *prior* to your object being instantiated -- you can verify this by
> printing out the value in your constructor:
I would consider the following as an alternative:
class foo
{
int bar() { return 50; }
};
"foo::bar()" would be compiled as inline code, and the compiler may then
bring the 50 into the expression being evaluated as a literal for further
optimization analysis.
---
Brian V. McGroarty -- brianmcg@bix.com -- phone/fax (708) 439-7714
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<9510150303.memo.3671@BIX.com>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: brianmcg@BIX.com Newsgroups: comp.std.c++ Subject: Re: Can I declare private constants? Date: 15 Oct 1995 14:39:04 GMT Organization: ? Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <9510150303.memo.3671@BIX.com> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text Content-Transfer-Encoding: 7BIT To: thoff@symantec.com Cc: std-c++@ncar.ucar.edu X-Cosy-To: thoff@symantec.com X-Cosy-Cc: std-c++@ncar.ucar.edu Content-Length: 532 Originator: clamage@taumet