[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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 {
  private:
    static int x;
};

and

class A {
  public:
    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.

Yup,

static int x;

is not exported.

-- 
Carlo Wood <carlo@alinoe.com>