Sizeof:- time operator sizeof is a unray compile time 
operator that returns the length of variable or 
parenthesized type specifierthat it precedes. 
ex:- sizeof (type) [where type is c++ datatype] 
ex:- sizeof(int); 
The comma operator 
a pair of expressions separated by a comma is evaluated 
left to right. 
Z= (a=1, a+5) / * bracket evaluates 6 and thus is the value 
assigned to Z.
Type casting 
The process of converting one predefined type into another is called type casting. 
type conversion have two forms:- 
implicit type conversion 
explicit type conversion 
Implicit type conversion:- the process of converting one predefined type into 
another performed by compiler without programmer’s intervention. it is applied 
generally whenever different data types are intermixed in an expression. 
ex:- long double 
It either operand is of type long double the other is converted to long double. 
Explicit type conversion:- Explicit type conversion is user defined that forces an 
expression to be a specific type. 
ex:-void main () 
{ 
int x=65; 
cout<<x<<endl; 
cout<<(char)x; //explicit type casting 
} 
output:- 65 
A
C ++ shorthands 
C++ offers special shorthands that simplify the coading of certain type 
of assignment statements. 
ex:- a=a+10 
can be written as, 
a+ =10 
some examples of c++ shorthands:- 
X- =10 Equivalent 
to 
X= X-10; 
X*=3 Equivalent to X=X*3; 
X/=2 Equivalent to X=X/2 
X%=z Equivalent to X=X/Z
Properties of variable can be describe by two ways:- 
Data type 
Storage class specifier 
Complete declaration for variable:- 
Storage_ class_ specifier datatype variable name; 
FOUR TYPES OF STORAGE CLASS SPECIFIER:- 
Automatic (local to block) 
When variable are declared in the beginning of a block they are automatically 
created by assigning the memory. The values of such variable are garbage. 
Therefor they are also called automatic variable. All such variable gets destroyed 
whenever their scope ends. 
Eg:- 
void fun 
{ 
int a; /* local to fun block*/ 
} 
Void fun1 
{ 
int a; /* local to fun1 block*/ 
}
Static – a variable when declared static gets initialized by zero or by 
a specific value only for the first time at the time of declaration. Such 
variable retain their value throughout the life time of variable. 
void () 
{ 
int i, sum=0; //sum is declared as static variable 
for (i= 0; i<=10; i++) 
{ 
sum= sum +i; 
} 
cout<<”nSum is =”<<sum; 
} 
Extern:- variable when defined outside the program file but used in 
the current file are used after linked them using extern keyword in 
declaration. 
Register:- its concept is in low level programming language there is 
no any use in high level language.
Global ( outside all scope) 
When variable is declared outside of all scope as it is visible 
throughout the main program and its associated function with 
specific value are initialized by zero , 
int a ; /* global variable*/ 
void main () 
{ } 
Scope resolution operator(::) - When name of local and global 
variable is same then to distinguish between these two variables 
we use scope resolution operator it denotes global variable only. 
Ex:- 
int a = 10 ; /* global variable*/ 
void main () 
{ 
int a = 100; /*local variable */ 
cout<<”a = ”<<a<<” “<<”::a =”<<::a; 
} 
Output:-a = 100 ::a = 10

C++ quik notes

  • 2.
    Sizeof:- time operatorsizeof is a unray compile time operator that returns the length of variable or parenthesized type specifierthat it precedes. ex:- sizeof (type) [where type is c++ datatype] ex:- sizeof(int); The comma operator a pair of expressions separated by a comma is evaluated left to right. Z= (a=1, a+5) / * bracket evaluates 6 and thus is the value assigned to Z.
  • 3.
    Type casting Theprocess of converting one predefined type into another is called type casting. type conversion have two forms:- implicit type conversion explicit type conversion Implicit type conversion:- the process of converting one predefined type into another performed by compiler without programmer’s intervention. it is applied generally whenever different data types are intermixed in an expression. ex:- long double It either operand is of type long double the other is converted to long double. Explicit type conversion:- Explicit type conversion is user defined that forces an expression to be a specific type. ex:-void main () { int x=65; cout<<x<<endl; cout<<(char)x; //explicit type casting } output:- 65 A
  • 4.
    C ++ shorthands C++ offers special shorthands that simplify the coading of certain type of assignment statements. ex:- a=a+10 can be written as, a+ =10 some examples of c++ shorthands:- X- =10 Equivalent to X= X-10; X*=3 Equivalent to X=X*3; X/=2 Equivalent to X=X/2 X%=z Equivalent to X=X/Z
  • 5.
    Properties of variablecan be describe by two ways:- Data type Storage class specifier Complete declaration for variable:- Storage_ class_ specifier datatype variable name; FOUR TYPES OF STORAGE CLASS SPECIFIER:- Automatic (local to block) When variable are declared in the beginning of a block they are automatically created by assigning the memory. The values of such variable are garbage. Therefor they are also called automatic variable. All such variable gets destroyed whenever their scope ends. Eg:- void fun { int a; /* local to fun block*/ } Void fun1 { int a; /* local to fun1 block*/ }
  • 6.
    Static – avariable when declared static gets initialized by zero or by a specific value only for the first time at the time of declaration. Such variable retain their value throughout the life time of variable. void () { int i, sum=0; //sum is declared as static variable for (i= 0; i<=10; i++) { sum= sum +i; } cout<<”nSum is =”<<sum; } Extern:- variable when defined outside the program file but used in the current file are used after linked them using extern keyword in declaration. Register:- its concept is in low level programming language there is no any use in high level language.
  • 7.
    Global ( outsideall scope) When variable is declared outside of all scope as it is visible throughout the main program and its associated function with specific value are initialized by zero , int a ; /* global variable*/ void main () { } Scope resolution operator(::) - When name of local and global variable is same then to distinguish between these two variables we use scope resolution operator it denotes global variable only. Ex:- int a = 10 ; /* global variable*/ void main () { int a = 100; /*local variable */ cout<<”a = ”<<a<<” “<<”::a =”<<::a; } Output:-a = 100 ::a = 10