Remember algebra, when you had those crappy questions like 3y - 9 = 12 and you had to figure out what "y" was equal too? Well, "y" was the variable. Well... what exactly is y equal too? In the given expression, "y" would be equal to 7... because 3*7-9 = 12. So, we can say the following;

y = 7

Now, whenever we use the variable "y" the program will instantly know that we mean "7."

In C++ however, we must tell the program which type of data is represented by the variable, such as int, double or char. We must also be careful how we name our variables. For example; Names MUST start with either a letter or an underscore character, you cannot use C++ keywords as variable names and C++ is case sensitive! Here are some examples of how to properly initialize variables.

int _number = 10; //creates a variable of int type, named number with a value of 10
int cash = 40; //creates a variable of int type, named cash with a value of 40.
string name123 = "johnny"; //creates a variable of string type, named name, with a value of johnny
char firstLetter = 'j'; //creates a variable of char type, named firstletter, with a value of j
double money = 12.2543; //creates a variable of double type, named money, with a value of 12.25.

*remember, we need to put the semi-colon at the end of the declaration so that C++ knows we're done with our statement.

If you grow tired and weary of typing the same datatype declaration over and over, you can use typedef to change it, such as doing something like...

At 2/23/06 08:51 AM, Glaiel_Gamer wrote:
if you want really large numbers you can use __int64 (2 underscores) as a type but then a lot of the math functions turn up errors cause they dont work with that type.

At 2/23/06 08:51 AM, Glaiel_Gamer wrote:
if you want really large numbers you can use __int64 (2 underscores) as a type but then a lot of the math functions turn up errors cause they dont work with that type.

Actually, a bool generally still takes up 1 byte of memory, even though logically it only takes up 1 bit -- the reason for this being is that computers generally allocate and access memory in terms of bytes and word size.