const int BUF_SIZE = 512;
	static const int BUF_SIZE = 512;	//Static is needed when defining at class level

#define may also be used, e.g.:-

	#define	VIDEO_LOG_PATH "C:\\Video_Log_Archive"
const objects are local to a file by default

Unlike other variables, const variables declared at global scope are local to the file in which the object is created. To use across different files:-
In file 1:

	extern const int BUF_SIZE = 512;	//Declaration must include extern as well as value

In file 2, 3, 4…:

	extern const int BUF_SIZE;		//There is no value which signifies that the cost is external

However, the reason for this is that a const can be used in a header file in the same way as #define – if doing that then there is no need to use extern as every file that needs the const value will be including the header file which will have the const with its scope always being local to that file rather than global.

Creating a constant lookup table in a class

	static array<Byte> ^encryptionKey = {0x45, 0x12, 0x67};

Using const is not permitted (if you have static const array… you get a warning saying const not supported but it will still compile).

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.