|
| To | Do this |
|---|---|
| Declare a variable. | Specify the type followed by spaces and then the variable name followed by a semicolon. For example: int number1; long longNumber1; |
| Assign values to a variable. | Use the assign operator =. |
| Group homogenous data together. | Use an array. |
| Prevent data from being changed. | Make the variable a constant. For example: const int x = 10; |
| Restrict the values a variable can accept to a small set. | Declare an enumerated constant, and declare the variable to be of that type. |
| Add member variables to a class. | Use the Add Member Variable Class Wizard. |
| Access a String class. | Use the .NET String class. |
| Find the size of an object or a type. | Use the sizeof() operator. |
| Convert one data type to another. | Use the static_cast<type> operator. |
| Override default operator precedence, or make the code more readable. | Use parentheses to group operators. |
|