What is C++ ?
C++ is an object oriented programming language. It is a superset of the 'C' programming language. In addition to the facilities provided by C, C++ provides flexible and efficient facilities for defining new types. A programmer can partition an application into manageable pieces by defining new types that closely match the concept of the application.
The technique for program construction is often called Data Abstraction. Objects of some user defined types contains type information. Such object can be used conveniently and safely in contexts in which their types can't be determined at compile time.
Programs using objects of such type often called object based. When used well these techniques results in shorter, easier to understand and easier to maintain programs. The key concept of C++ is class.
C++ Character set
The C++ characters sets consists of the upper and lower case alphabets, digits, special characters and white space. The alphabets and digits together constitute and alphanumeric set. The compiler ignores white space unless they are a part of a string constant. White space are used to separate words nut cannot be embedded in the keywords and identifiers. Complete character set is written below.
Alphabets-
Uppercase: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Lowercase: a b c d e f g h i j k l m n o p q r s t u v w x y z
Digits-
0 1 2 3 4 5 6 7 8 9
Special Characters-
, comma
. period
; semicolon
: colon
# number sign
' apostrophe
" quotation mark
! exclamation mark
| vertical bar
~ tilde
< opening angle bracket
> closing angel bracket
_ underscore
$ dollar sign
% percent sign
? question mark
& ampersand
^ caret
* asterisk
- minus sign
+ plus sign
( left parenthesis
) right parenthesis
[ left bracket
] right bracket
{ left brace
} right brace
/ slash
\ backslash
White space characters-
What are Tokens ?
The smallest individual units in a program are known as tokens.
C++ has following tokens-
1) Keywords
Given below the complete set of C++ keywords.
asm
catch
class
delete
friend
inline
new
operator
private
protected
public
template
this
throw
try
Added by ANSI C
auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while
Added by ANSI C++
bool
export
reinterpret_cast
typename
const_cast
false
static_cast
using
dynamic_cast
mutable
true
wchar_t
explicit
namespace
typeid
2) Identifier
They are refer to the names of variables, functions, arrays, classes, etc. created by the programmer. They are fundamental requirement of any language. Each language has its own rules for naming these identifiers. The following rules are common for both C and C++
- Only alphabetic characters, digits and underscores are permitted.
- The name cannot start with a digit.
- A declared keyword cannot be used as a variable name.
- Uppercase and Lowercase letters are distinct.
3) Constant
4) Strings
A string is a sequence of characters.