C++ Logo

std-discussion

Advanced search

Const

From: Russell Shaw <rjshaw_at_[hidden]>
Date: Fri, 15 Nov 2024 09:40:02 +1100
Hi,

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;
-------------------------------

How do i define consts without memory locations and without a struct (or macros) ?

-------------------------------
const int x = 0; // uses memory
const int y = 0;
const int z = 0;

int a = x;
-------------------------------

Received on 2024-11-14 22:40:13