MESSAGE
DATE | 2010-02-10 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] C++ Workshop _ Syntax Basics
|
Statement Structure:
All C and C++ statements (although not all syntax) ends with a semi-colon. You can even put two semi-colons on a single line, seperated by a semicolon, but in general this isn't recommend.
Statements are constructed with Data, Operators and Keywords. C++ has an exented set of Keywords than C.
Keywords:
Keywords are any symbols that the Standard C++ recognizes as having instructional meaning, that is the tell the compiler to do something. The Key Words in C++ are as follows, and learning the exact meaning of all the keywords is essential to learning C++.
These are inhereted from C:
auto const double float int short struct unsigned break continue else for long signed switch void case default enum goto register sizeof typedef volatile char do extern if return static union while
These are the extended set added to C++
asm dynamic_cast namespace reinterpret_cast try bool explicit new static_cast typeid catch false operator template typename class friend private this using const_cast inline public throw virtual delete mutable protected true wchar_t
and most C++ Compilers also recognize the follow Keywords
and bitand compl not_eq or_eq xor_eq and_eq bitor not or xor
Keywords are completely reserved and can not be used as symbols by any user defined variables in your program. They are exclusive to the language and compilers.
There are other important predefined symbols that C++ uses as well. These are not strictly exclusive to the Language, however, overloading them or using them as symbols for variables is a very bad idea.
There is a lot of them, but some of them might include
cin endl INT_MIN iomanip main npos std cout include INT_MAX iostream MAX_RAND NULL string not to mention the Macros like __DATE__ and __TIME__
Operators:
Operators, are very much like functions or methods in that they define processes, taking in arguments and returning outputs (and having side affects). In the C Language, Operators are immutable. You can't change their meaning. In C++ many of them can be overloaded, that is that you can create, and change their meaning. A lot of C++ study involves discussing the overloading of Operators.
All Operators, as they do in Mathematics, have precedence and associativity. For example, in arithmetic:
4 x 3 - 10 = 22
and not -28 or 2. That is because multiplication has a higher precedence that subtraction and the associativity is left to right. A complete list of C++ operators is considerable and as follows:
????????????????????????????????????????????????????????????????????????????????????? ? Operator ? Type ? Associativity ? ????????????????????????????????????????????????????????????????????????????????????? ? :: ? binary scope resolution ? ? ? :: ? unary scope resolution ? ? ???????????????????????????????????????????????????????????????????? ? ? () ? parentheses ? ? ? [] ? array subscript ? ? ? . ? member selection via object ? ? ? -> ? member selection via pointer ? left to right ? ? ++ ? unary postincrement ? ? ? -- ? unary postdecrement ? ? ? typeid ? run-time type information ? ? ? dynamic_cast< type > ? run-time type-checked cast ? ? ? static_cast ? compile-time type-checked cast ? ? ? reinterpret_cast ? cast for non-standard conversions ? ? ? const_cast ? cast away const-ness ? ? ????????????????????????????????????????????????????????????????????????????????????? ? ++ ? unary preincrement ? ? ? -- ? unary predecrement ? ? ? + ? unary plus ? ? ? - ? unary minus ? ? ? ! ? unary logical negation ? ? ? ~ ? unary bitwise complement ? ? ? ( type ) ? C-style unary cast ? right to left ? ? sizeof ? determine size in bytes ? ? ? & ? address ? ? ? * ? dereference ? ? ? new ? dynamic memory allocation ? ? ? new[] ? dynamic array allocation ? ? ? delete ? dynamic memory deallocation ? ? ? delete[] ? dynamic array deallocation ? ? ????????????????????????????????????????????????????????????????????????????????????? ? .* ? pointer to member via object ? ? ? ->* ? pointer to member via pointer ? ? ???????????????????????????????????????????????????????????????????? ? ? * ? multiplication ? ? ? / ? division ? ? ? % ? modulus ? ? ???????????????????????????????????????????????????????????????????? ? ? + ? addition ? ? ? - ? subtraction ? ? ???????????????????????????????????????????????????????????????????? ? ? << ? bitwise left shift ? ? ? >> ? bitwise right shift ? ? ???????????????????????????????????????????????????????????????????? ? ? < ? relational less than ? ? ? <= ? relational less than or equal to ? left to right ? ? > ? relational greater than ? ? ? >= ? relational greater than or equal to ? ? ???????????????????????????????????????????????????????????????????? ? ? == ? relational is equal to ? ? ? != ? relational is not equal to ? ? ???????????????????????????????????????????????????????????????????? ? ? & ? bitwise AND ? ? ???????????????????????????????????????????????????????????????????? ? ? ^ ? bitwise exclusive OR ? ? ???????????????????????????????????????????????????????????????????? ? ? | ? bitwise inclusive OR ? ? ???????????????????????????????????????????????????????????????????? ? ? && ? logical AND ? ? ???????????????????????????????????????????????????????????????????? ? ? || ? logical OR ? ? ????????????????????????????????????????????????????????????????????????????????????? ? ?: ? ternary conditional ? ? ???????????????????????????????????????????????????????????????????? ? ? = ? assignment ? ? ? += ? addition assignment ? ? ? -= ? subtraction assignment ? ? ? *= ? multiplication assignment ? ? ? /= ? division assignment ? right to left ? ? %= ? modulus assignment ? ? ? &= ? bitwise AND assignment ? ? ? ^= ? bitwise exclusive OR assignment ? ? ? |= ? bitwise inclusive OR assignment ? ? ? >>= ? bitwise left shift assignment ? ? ? <<= ? bitwise right shift with assignment ? ? ????????????????????????????????????????????????????????????????????????????????????? ? , ? comma ? left to right ? ?????????????????????????????????????????????????????????????????????????????????????
We will walk through this complete list of operators later.
-- http://www.mrbrklyn.com - Interesting Stuff http://www.nylxs.com - Leadership Development in Free Software
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998
http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
"Yeah - I write Free Software...so SUE ME"
"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."
"> I'm an engineer. I choose the best tool for the job, politics be damned.< You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."
? Copyright for the Digital Millennium
|
|