Top "Class-constants" questions

In object-oriented programming, a class constant is a constant defined within a class.

How to implement class constants?

In TypeScript, the const keyword cannot be used to declare class properties. Doing so causes the compiler to an error …

typescript class-constants
Can I get CONST's defined on a PHP class?

I have several CONST's defined on some classes, and want to get a list of them. For example: class Profile { …

php constants class-constants
Why constant data member of a class need to be initialized at the constructor?

I want to know why constant data member of a class need to be initialized at the constructor and why …

c++ constructor class-constants
What is the purpose of the Java Constant Pool?

I am currently trying to dig deeper into the specification of the Java Virtual Machine. I have been reading Inside …

java vm-implementation class-constants
Get value of dynamically chosen class constant in PHP

I would like to be able to do something like this: class ThingIDs { const Something = 1; const AnotherThing = 2; } $thing = 'Something'; $id = …

php class-constants
How to I make private class constants in Ruby

In Ruby how does one create a private class constant? (i.e one that is visible inside the class but …

ruby access-specifier class-constants
Can traits have properties & methods with private & protected visibility? Can traits have constructor, destructor & class-constants?

I've never seen a single trait where properties and methods are private or protected. Every time I worked with traits …

php constructor visibility traits class-constants
Is it possible to define a class constant inside an Enum?

Python 3.4 introduces a new module enum, which adds an enumerated type to the language. The documentation for enum.Enum provides …

python python-3.x enums constants class-constants
php class constant visibility

Can we set visibility of class constant? For this example: class MyClass { const CONST_VALUE = 'A constant value'; } Can we …

php class-constants
Get class constant names in php?

I have a php class with some class constants that indicate the status of an instance. When I'm using the …

php oop class-constants