IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesC++/CLI  Print This     

Constants (C++/CLI and Access VBA Cross Reference Guide)

By Mike Prestwood

C++/CLI versus Access VBA: A side by side comparison between C++/CLI and Access VBA.

 
Language Basics
 

Language basics is kind of a catch all for absolute beginner stuff. The items (common names) I chose for language basics is a bit random and include items like case sensitivity, commenting, declaring variables, etc.

Constants

[Other Languages] 

General Info: Computer Language Constants

A constant is just like a variable (it holds a value) but, unlike a variable, you cannot change the value of a constant.

C++/CLI:   const or literal

C++/CLI supports the const and static const keywords of standard C++ as well as the new literal keyword. A literal is equivalent to static const in standard C++ and Microsoft's documentation recommends to replace static const with the new literal keyword because a literal is available in metadata; a static const variable is not available in metadata to other compilers.

You can use static const within the class declaration or locally within a method. However, literal is only valid in the class declaration section and const is only valid within a method.

Syntax Example:  
//some method {
const String^ MyName = "John";
static const Int32 MyAge = 27;
//}
// public class SomeClass : public Object {
public:
  literal double Pi = 3.14159;
  literal String^ MyName = "Mike";
  static const Int32 MyAge = 35;
//...
Access VBA:   Const kPI = 3.1459

Scope can be Public, Global, or Private. The use of the newer Public keyword is preferred to the older Global. Private Const is the same as just specifying Const.

Syntax Example:
Const kPI = 3.1459
Const kName = "Mike"
 
//Public variable:
Public Const kFeetToMeter=3.28, kMeterToFeet=.3












Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]