Top "Constants" questions

Constants in programming are definitions whose value is fixed throughout a program's execution.

Purpose of returning by const value?

What is the purpose of the const in this? const Object myFunc(){ return myObject; } I've just started reading Effective C++ …

c++ constants
const vs constexpr on variables

Is there a difference between the following definitions? const double PI = 3.141592653589793; constexpr double PI = 3.141592653589793; If not, which style is preferred …

c++ variables c++11 constants constexpr
Variably modified array at file scope

I want to create a constant static array to be used throughout my Objective-C implementation file similar to something like …

c objective-c arrays static constants
Creating a constant Dictionary in C#

What is the most efficient way to create a constant (never changes at runtime) mapping of strings to ints? I've …

c# .net collections dictionary constants
Constants in Kotlin -- what's a recommended way to create them?

How is it recommended to create constants in Kotlin? And what's the naming convention? I've not found that in the …

android kotlin constants
Importing a long list of constants to a Python file

In Python, is there an analogue of the C preprocessor statement such as?: #define MY_CONSTANT 50 Also, I have a …

python constants python-import
Define constant variables in C++ header

A program I am working on has many constants that apply throughout all classes. I want to make one header …

c++ header constants
Why can't I initialize non-const static member or static array in class?

Why can't I initialize non-const static member or static array in a class? class A { static const int a = 3; static …

c++ static constants
How can I get the size of an std::vector as an int?

I tried: #include <vector> int main () { std::vector<int> v; int size = v.size; } but got …

c++ vector size constants unsigned-integer
Is it better in C++ to pass by value or pass by constant reference?

Is it better in C++ to pass by value or pass by constant reference? I am wondering which is better …

c++ variables pass-by-reference constants pass-by-value