C++ Logo

std-discussion

Advanced search

Re: Const

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 14 Nov 2024 15:52:34 -0700
On Thursday 14 November 2024 15:40:02 Mountain Standard Time Russell Shaw via
Std-Discussion wrote:
> I can define consts without memory locations like:
>
> -------------------------------
> struct S {
> static const int x = 0;
> static const int y = 0;
> static const int z = 0;
> };
>
> int a = S::x;
> -------------------------------

Incorrect. If you ODR-use the above, your linker will likely fail.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2024-11-14 22:52:37