Object Oriented Programming 2
Object Oriented Programming 2
Programming 2
Tokens in C++
Keywords- These are the explicitly reserved identifiers that cannot
be used as names for the program variables or other user defined
program elements.
eg.auto, break, if, else, float, int etc
Identifiers- The name of variables, functions, array, classes etc.
created by the programmer.
Rule 1: Only alphabetic characters, digits and underscores are
premitted.
Rule 2: The name cannot start with a digit
Rule 3: Upper case and Lower case letters are distinct.
Rule 4: A declared keyword cannot be used as a variable name
Note**: ANSI C recognizes only the first 32 characters in a name while
ANSI C++ places no limit on its length and recognizes all the characters.
Anonymous enums
Eg. enum{off, on};
int switch_1=off
int switch_2=on;
break;
case rectangle:
break;
case triangle:
break;
}
cout << Enter shape
code:;
cin >> code;
}
cout << BYE \n;
return 0;
}
Note**:
ANSI
C
permits an enum to
be defined within a
structure or a class
but the enum is
globally visible. In
C++,
an
enum
defined
within
a
class(or structure) is
local to that class(or
structure) only.
//pointer to a constant
C++ Operators
::
::*
->*
.*
delete
endl
new
setw
//Block 1
// Block 2
//global m
int [4][5][6];
int [size][5][6];
int[4][5][];
int[][5][6];
//correct
//correct
//incorrect
//incorrect
or
int x=y=10;
declaration
x=y=10;
//Wrong to use chain assignment at the time of
Embedded Assignment
x=(y=50)+10 equivalent to
y=50; x=y+10;
Compound Assignment
x=x+10; can be written as x+=10;
Thank You