[LC++]enum, #define, const, static const, or member const???

Carlo Wood carlo at alinoe.com
Fri Apr 5 23:02:05 UTC 2002

On Fri, Apr 05, 2002 at 11:53:36AM +0100, Vincent Penquerc'h wrote:
> Making something private implies it is part of a class, so it is
> not in the global namespace anyway.

That is not correct.  'private' controls the accessibility: whether
or not you are allowed to access in (by de compiler).  It has no
effect whatsoever on the linker-level.

The declarations

class A {
    static int x;


class A {
    static int x;

both need a definition

int A::x;

and 'A::x' is being exported (or in "global namespace" as you call it).

'x' is not global namespace of course, but that has nothing to do
with it being private or not.

> static (at global scope) means that the particular identifier
> won't be exported, so won't pollute the global namespace. Note
> that the static keyword in other places does not mean that.


static int x;

is not exported.

Carlo Wood <carlo at alinoe.com>

More information about the tuxCPProgramming mailing list