constants

Why are there defined constants and declared constants in CPP?

Why are there two ways to "declare" constants in CPP? Which is better, or should I write, which of them should I use when? #define MYCON 100 const int MYCON=100 ...

Scope of Constants in Ruby Modules

I'm having a little problem with constant scope in mixin modules. Let's say I have something like this module Auth USER_KEY = "user" unless defined? USER_KEY def authorize user_id = session[USER_KEY] def end The USER_KEY constant should default to "user" unless it's already defined. Now I might mix this into a couple of p...

What is the problem with this code?

The compile error I'm getting is "newline in constant" The error occurs where the four asterisks are (****). I can't debug, because the solution won't build successfully. <script type="text/javascript"> function TNClicked(fullImgURL, TNID) { document.getElementById("<%= this.imgFull.ClientID %>").src = fullImgURL; var pnlFullIm...

Delphi: All constants are constant, but some are more constant than others?

Consider: const clHotlight: TColor = $00FF9933; clLink = clHotLight; //alias of clHotlight [Error] file.pas: Constant expression expected and the alternate wording that works: const clHotlight = TColor($00FF9933); clLink = clHotLight; //alias of clHotlight Explain. Then consider: const AdministratorGUID: TGUI...

Simple question about C++ constant syntax

Here is some code copied from Thinking in C++ Vol1 Chapter 10. #include <iostream> using namespace std; int x = 100; class WithStatic { static int x; static int y; public: void print() const { cout << "WithStatic::x = " << x << endl; cout << "WithStatic::y = " ...

How can you represent mathematical constant "e" as a value in JavaScript?

How can you represent mathematical constant "e" as a value in JavaScript? ...

Is it faster to access a property file or static constants from a class file?

I develop a webservice application in a tomcat container, I have a lot of properties for the webapp like constants, error messages and so on. What is the better and faster way to? ...

Why is there no Constant keyword in Java?

I was trying to identify the reason behind the "CONSTANTS" in Java I have learnt that Java allows us to declare constants by using final keyword. My question is why didn't Java introduce Constant (const) keyword. Since many people say it has come from C++, in C++ we have const keyword. Please share your thoughts. ...

C#: How do you manage symbolic constants in your projects? Where do you declare solution scope constants ?

How do you manage symbolic constants in your projects? Where do you declare solution scope constants ? ...

Variables versus constants versus associative arrays in PHP

I'm working on a small project, and need to implement internationalization support somehow. I am thinking along the lines of using constants to define a lot of symbols for text in one file, which could be included subsequently. However, I'm not sure if using variables is faster, or if I can get away with using associative arrays without ...

define constant in php

how do I define a constant inside a function eg. class { public test; function tester{ const test = "abc"; } } ...

Is there a a C-like way to get item number from enum in java ?

Perhap this is a simple basic question Having an enum public enum TK{ ID,GROUP,DATA,FAIL; } Can I get the order number for example ID=0, GROUP=2, DATA=3, FAIL=4 ? This is a way to to that, but a weird and long one! =S public enum TK{ ID(0),GROUP(1),DATA(2),FAIL(3); int num; TK(int n) ...

Where are constant NSStrings allocated?

I understand that constant CStrings are allocated statically, rather than on the heap. I also noticed that constant NSStrings have an infinite retain count. Does it hold true that constant NSStrings are also allocated statically, rather than on the heap? ...

Problems initializing a final variable in Java

I keep running into slight variations of a problem in Java and it's starting to get to me, and I can't really think of a proper way to get around it. I have an object property that is final, but dynamic. That is, I want the value to be constant once assigned, but the value can be different each runtime. So I declare the class level vari...

Constant member

I have structure defined in some header (D3DXVECTOR3) How can I declare: static member in the class of that type and initialize it? maybe constant member of that type and init it? when i use some constructor i get error only integral can be initialized. ...

Common constants file for PHP and JavaScript

How do guys suggest to share a constants file between PHP and JavaScript, in order not to repeat code? XML file? I am assuming mixing up javascipt inside PHP would not be the right solution!? Thanks ...

Can I use string concatenation to define a class CONST in PHP?

I know that you can create global constants in terms of each other using string concatenation: define('FOO', 'foo'); define('BAR', FOO.'bar'); echo BAR; will print 'foobar'. However, I'm getting an error trying to do the same using class constants. class foobar { const foo = 'foo'; const foo2 = self::foo; const bar = self::f...

C++: Define simple constant for use?

In C++ I wanted to define a constant that I can use in another function, A short answer on how to do this will be fine.. Lets say at the beginning of my code I want to define this constant: //After #includes bool OS = 1; //1 = linux if (OS) { const ??? = "clear"; } else { const ??? = "cls"; } I don't know what type to use to def...

Is there a config option in PHP to prevent undefined constants from being interpreted as strings?

This is from the php manual: http://us.php.net/manual/en/language.constants.syntax.php If you use an undefined constant, PHP assumes that you mean the name of the constant itself, just as if you called it as a string (CONSTANT vs "CONSTANT"). An error of level E_NOTICE will be issued when this happens. I really don't like this be...

Can you use constant variables in javascript?

Hi I am using visual studios 2010 and created a javascript file(jscript.js) and I saw on one page saying you can make constant variables in javascript like: const x = 20; bu to on another page I read it says you can't. So I am confused now what is it now? Also in Visual studios when I write "const" it underlines it in the javascript...