Introduction to C++, Character set and Tokens

C++, Character set and Tokens


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-

blank space
formfeed
newline
carriage return
horizontal tab
vertical tab

What are Tokens ?

The smallest individual units in a program are known as tokens.

C++ has following tokens-

1) Keywords

The keywords are explicitly reserved identifier and cannot be used as names for program variable or other user-defined program elements. It means that they have predefined meaning and cannot be changed by the user.

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

Constants refer to fixed values that do not change during the execution of a program. Like C, C++ supports several kinds of literal constants. They include integers, characters, floating points numbers and string. Literal constant do not have memory locations.

4) Strings

A string is a sequence of characters.

5) Operators

C++ has a rich set of operators. All C operators, such as arithmetic, relational, logical, assignment, increment, decrement, conditional, bitwise and special are valid in C++ also. In addition, C++ introduces some new operators which are - 
<< Insertion operator
>> Extraction operator
:: Scope resolution operator
::* Pointer-to-member declarator
->* Pointer-to-member operator
.* Pointer-to-member operator
delete Memory release operator
endl Line feed Operator
new Memory allocation operator
setw Field width operator

Previous Post Next Post

Responsive Ad