OOP:- OOP stands for Object-Oriented Programming. It is a better approach to programming over the old
approach so-called Procedural programming.
C++ CHARACTER SET:-
LETTERS: 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,
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 SYMBOLS: + - * \ / = ! < > ( ) { } [ ] , . ? : ; ‘ “ | `
~ & ^ % $ # @ _ ;
WHITE SPACES: Blank Space, Horizontal Tab, Carriage Return, Newline, Form feed;
OTHER CHARACTERS: 256 ASCII characters;
TOKENS:-
The token is a fragment of a statement separate from the rest by white space(s)
and is similar to that of a word of the English literature.
The smallest individual unit in a program is known as a token.
TYPES OF TOKENS:-
1). Keywords:-
(Reserve-words) Keywords are those words that convey a special meaning to the language
compiler.
I). Selection statements:-
if:
else:
* nested if (else if)
switch
II). Loop:-
Iteration:
while: III).
continue:
break:
2). Identifiers:-
An identifier is a long sequence of letters and digits.
*Rules for naming/creating an identifier:-
(1). The identifier must start either with an alphabet or with _ (underscore).
(2). The identifier should not start with digits (0-9), but it can contain them in between.
(3). An identifier must not contain more than 256 characters.
(4). The identifier must not contain a special character.
(5). The identifier should not be the same as a reserved word of the IDE.
(6). Since everything in C, C++ language is case-sensitive, so it should always be considered.
3). Literals:-
(Constants) Literals are data items that never change their value during the execution of
the program;
Types of literals:-
(I). Integer-constants: Integer-constants are whole numbers without any fractional part.
*Rule for creating an integer constant:
(1). An integer constant must have at least 1 digit
(2). An integer must not contain a decimal point.
(3). It may contain a +, - sign; A number no sign is considered to be positive.
(4). There should not be any comma (,) in between.
There are 3 different types of integer constants:
(1). Decimal Integer constants (base-10): An integer constant that does not start with 0
is said to be a decimal integer constant.
(2). Octal Integer constants (base-8): An integer constant that starts with 0 is said to be
an octal integer constant.
(3). Hexadecimal Integer constants (base-16): An integer constant starting with x0 or X0
is said to be a hexadecimal integer constant.
(II). Character constants: A character constant is one character enclosed in single quotes.
*Rule for creating a character constant:
(1). A character constant must contain only 1 character.
(2). It should be enclosed within single quotes (‘ ‘). (III). Floating constants: (Real constants) Floating constants are real numbers having fractional parts.
It can be written in the following 2 forms:
(I). Fractional form:
*Rule for writing a floating constant (Fractional form):
(1). A floating constant must have at least 1 digit.
(2). A floating constant containing fractional part must contain at least one digit before the
decimal point and 1 digit after the decimal point.
(3). It may contain a +, - sign; A number no sign is considered to be positive.
(4). There should not be any comma (,) in between.
(II). Exponent form: A floating constant in exponent form contains two parts:
1) Mantissa: That part of the floating constant in exponent form, which is before the E or e
of the number is said to be the mantissa.
2) Exponent: That part of the floating constant in exponent form which is behind the E or e
of the number is said to be an exponent.
*Rule for writing a floating constant (Exponent form):
(1). The mantissa must be either an integer or a proper real constant.
(2). The mantissa must be followed by ‘et or ‘E’ and exponent.
(3). The exponent must be an integer.
4). Punctuators:-
It includes the following characters:
[ ] Brackets:
( ) Parentheses:
{ } Braces:
, Comma:
; Semicolon:
: Colon:
* Asterisk:
… Ellipses:
= Equal to sign:
# Pound sign:
5). Operators:-
Operators are tokens that trigger some computation when applied to variables and other objects in an expression.
Types of operators (Based on several required operators):-
I). Unary operators: Unary operators are those operators who require only one operator to
operate upon.
& Address operator.
* Indirection operator.
+ Unary plus.
- Unary minus.
~ Bitwise complement.
++ Increment operator.
-- Decrement operator.
! Logical negation operator.
II). Binary operators: Binary operators are those operators who require at least 2
operators to operate upon.
1).Arithmetic operators:
+ Addition.
- Subtraction.
* Multiplication.
/ Division.
% Remainder.
2). Shift Operators:
<< Shift left.
>> Shift right.
3). Bitwise operators:
& Bitwise AND.
^ Bitwise exclusive OR (XOR).
! Bitwise OR.
4). Logical operators:
&& Logical AND.
|| Logical OR.
5). Assignment operators:= Assignment.
*= Product assignment.
/= Assign quotient.
%= Assign remainder.
+= Assign sum.
-= Assign difference.
<<= Assign left shift.
>>= Assign right shift.
&= Assign bitwise AND.
^= Assign bitwise XOR.
!= Assign bitwise OR.
6). Relational operators:
< Less than.
> More than.
<= Less than or Equal to.
>= Greater than or Equal to.
== Equal to.
!= Not Equal to.
7). Component Selection Operators:
Direct component selector.
Indirect component selector.
8). Class member operators:
:: Scope access / resolution.
* Deference pointer to the class member.
->* Deference pointer to the class member.
9). Conditional operators:
?:
The order of precedence for operators is as follows:
( ) [ ] ->
! ~ + - ++ -- & *(typeset)
* / %
+ -
<< >>
< <= > >>=
== !=
&
do-while:
for:^
|
&&
||
?:
= *= / =%= += -= &= ^= |= < <= >
>=
*Operators within the parentheses are performed first.
You must be logged in to post a comment.