Monday, September 29, 2008

Introduction to C++ -cont-

Escape Code

Escape codes are special characters that cannot be expressed otherwise in the source code of a program, like newline (\n) or tab (\t). All of them are preceded by an inverted slash (\). Here you have a list of such escape codes:

\n

newline

\r

carriage return

\t

tabulation

\v

vertical tabulation

\b

backspace

\f

page feed

\a

alert (beep)

\'

single quotes (')

\"

double quotes (")

\?

question (?)

\\

inverted slash (\)


Variable

We can define a variable as a portion of memory to store a determined value, and the value could change since the program is executed. Variable could consist of letter, numeric and underline symbol (_). Least they are three points we have to do in writing variable:

- Have to begin with letter

- Without space

- Cannot match with any key word in C++ language

For example, the following expressions are always considered key words according to the ANSI-C++ standard and therefore they must not be used as identifiers:

asm, auto, bool, break, case, catch, char, class, const, const_cast, continue, default, delete, do, double, dynamic_cast, else, enum, explicit, extern, false, float, for, friend, goto, if, inline, int, long, mutable, namespace, new, operator, private, protected, public, register, reinterpret_cast, return, short, signed, sizeof, static, static_cast, struct, switch, template, this, throw, true, try, typedef, typeid, typename, union, unsigned, using, virtual, void, volatile, wchar_t

Very important: The C++ language is "case sensitive", that means that an identifier written in capital letters is not equivalent to another one with the same name but written in small letters. Thus, for example the variable RESULT is not the same as the variable result nor the variable Result.

Constants

A constant is any expression that has a fixed value. They can be divided in Integer Numbers, Floating-Point Numbers, Characters and Strings



Source : Cplusplus.com

No comments: