際際滷

際際滷Share a Scribd company logo
 
OOPs
PlacementClass2013
23September
 
Pre足requisites

OSStack

Variables

Functions
 
TheStack

Call足Stack,
Execution足Stack,
Runtime足Stack,
Machine足Stack
 
Variables

A variable is an IDENTIFIER for a VALUE
 
Variables

A variable is an IDENTIFIER for a VALUE

IDENTIFIERS = (KEY WORDS) U
(QUALIFIED IDENTIFIERS)

QUALIFIED ID = (Var Names) U (Class
names) U (Function names) U ...
 
Variables

Question :

What is the difference between the
following :
 #definemyVar10
 intmyVar=10;
 
Variables
QUESTION:
Howwillthisprogrambehave?
Output?
 
Variables
 
Variables
MappingVAR足>Address
VALUE
 
Variables
MappingVAR足>Address
VALUE

WhynotdirectlyVAR足>VALUEmapping?

Differentdatatypeshavedifferentmemoryreqt

intcoolness=5;
DatatypeVariableNameValue
 
VariablesMemoryReqt

INT:4B

FLOAT:4B

DOUBLE:8B

LONGLONGINT:10B

POINTER(int*coolness)=32b/64b???
 
VariablesMemoryReqt

INT:4B

FLOAT:4B

DOUBLE:8B

LONGLONGINT:10B

POINTER(int*coolness)=32b/64b
 
ENDOFVARIABLES
 
Functions

Function has the following :

Return Type

Parameters

Function Name (Qualified Identifier)

Body
 
Functions

Function has the following in a
Programming language :

Return Type

Parameters

Function Name (Qualified Identifier)

Body
 
Functions

Function can be called (evoked) in 2
ways:

Call by REFERENCE

Call by VALUE
 
FunctionsCallbyreference

Pass the address of where the value is
stored in memory
 
FunctionsCallbyreference
OUTPUT?
 
FunctionsCallbyreference
 
FunctionsCallbyValue

MakesaCOPYoftheparameterspassed
andusestheCOPYinthefunctionbody
 
FunctionsCallbyValue

MakesaCOPYoftheparameterspassed
andusestheCOPYinthefunctionbody

Thisisaformofscopingtoo
 
FunctionsCallbyValue
OUTPUT?
 
FunctionsCallbyValue
 
FunctionsCallbyValue
 
FunctionsCallbyValue
Trivia+TrickQuestion!
 
FunctionsCallbyValue
 
FunctionsTRIVIA
15yearsback,beforeC++camein,
Address(cool)=Address(coolness)
WHY?
 
FunctionsTRIVIA
15yearsback,beforeC++camein,
Address(cool)=Address(coolness)
COMPILEROPTIMIZATION!
 
Next:OOPs

More Related Content

Object Oriented Programming : Part 1