Top "Constants" questions

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

Declare a const array

Is it possible to write something similar to the following? public const string[] Titles = { "German", "Spanish", "Corrects", "Wrongs" };

c# .net arrays constants readonly
Static constant string (class member)

I'd like to have a private static constant for a class (in this case a shape-factory). I'd like to have …

c++ string class static constants
'Static readonly' vs. 'const'

I've read around about const and static readonly fields. We have some classes which contain only constant values. They are …

c# constants
"static const" vs "#define" vs "enum"

Which one is better to use among the below statements in C? static const int var = 5; or #define var 5 or …

c constants
What is the difference between char s[] and char *s?

In C, one can use a string literal in a declaration like this: char s[] = "hello"; or like this: char *…

c string char constants
Difference between char* and const char*?

What's the difference between char* name which points to a constant string literal, and const char* name

c pointers constants
PHP Constants Containing Arrays?

This failed: define('DEFAULT_ROLES', array('guy', 'development team')); Apparently, constants can't hold arrays. What is the best way to …

php arrays constants scalar
How to initialize const member variable in a class?

#include <iostream> using namespace std; class T1 { const int t = 100; public: T1() { cout << "T1 constructor: " <&…

c++ constants
Use of 'const' for function parameters

How far do you go with const? Do you just make functions const when necessary or do you go the …

c++ constants
Meaning of 'const' last in a function declaration of a class?

What is the meaning of const in declarations like these? The const confuses me. class foobar { public: operator int () const; …

c++ constants declaration c++-faq