🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by brianmcg Sun, 15 Oct 1995 14:39
Re: Can I declare private constants?
#2200
Author: brianmcg
Date: Sun, 15 Oct 1995 14:39
21 lines
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. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads