This is a premium lesson. You can see the shape of every card — unlock to read them.
Unlock
PARAMETER PASSING IN C++ ஒரு function-ஐ call செய்யும்போது, calling f……
Premium
This card is part of the premium lesson.
Unlock
Parameter passing is the mechanism used to transfer values or variables from a calling function to……
Premium
This card is part of the premium lesson.
Unlock
Example
add(10, 20); இங்கு: 10, 20 என்ற values a……
Premium
This card is part of the premium lesson.
Unlock
இந்த program-ஐ பாருங்கள்: #incl……
Premium
This card is part of the premium lesson.
Unlock
Important terminology
Parameter passing-ல் இரண்டு ம……
Premium
This card is part of the premium lesson.
Unlock
1. Actual Parameter / Argumen……
Premium
This card is part of the premium lesson.
Unlock
Function call செய்யும்போது கொடுக்கப்ப……
Premium
This card is part of the premium lesson.
Unlock
Example
display(a); இங்கு: a Actual p……
Premium
This card is part of the premium lesson.
Unlock
FORMAL PARAMETER
Function definition-ல் value receive செய்ய பயன்படுத்தப்படும் var……
Premium
This card is part of the premium lesson.
Unlock
Example
add(a, b); } இங்கு: a, b → Actual Para……
Premium
This card is part of the premium lesson.
Unlock
main() | | a = 10 | b = 20 | | add(a,……
Premium
This card is part of the premium lesson.
Unlock
Types of parameter passing in c++
C++-ல் முக்கியமாக மூன்று para……
Premium
This card is part of the premium lesson.
Unlock
Call by Value
Call by Reference
Call by Address / Pointer
இதில் TRB, NET, SET, Intervie……
Premium
This card is part of the premium lesson.
Unlock
Comparison
vs
Premium
This card is part of the premium lesson.
Unlock
CALL BY VALUE
Function-க்கு original variable-ஐ அனு……
Premium
This card is part of the premium lesson.
Unlock
Example
Call: change(a); a முழுமையாக function-……
Premium
This card is part of the premium lesson.
Unlock
Program - call by value
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Question
Function-ல்: x = 100; என்று மாற்றினோம். அப்……
Premium
This card is part of the premium lesson.
Unlock
Line explanation
Initial: int a = 10; Memory concept: a +------+ | 10 | +------+ Function call: change(a); a value copy செய்யப……
Premium
This card is part of the premium lesson.
Unlock
Key point
Call by Value: Change in formal parameter does not affect the act……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Step 1
Step 2: change(a); Step 3: Va……
Premium
This card is part of the premium lesson.
Unlock
Step 4
Now
Step 5: Function ends. x dest……
Premium
This card is part of the premium lesson.
Unlock
CALL BY REFERENCE
Original variable-க்கு ஒரு reference / alias function parameter ஆக……
Premium
This card is part of the premium lesson.
Unlock
void functionName(int &x) { }…
Premium
This card is part of the premium lesson.
Unlock
int &x இதன் பொருள்: x என்பது தன……
Premium
This card is part of the premium lesson.
Unlock
Program - call by reference
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Why output 100?
Initial: a = 10 Function call: change(a); Function parameter: int &x x என்பது a-க்கு reference. Conceptua……
Premium
This card is part of the premium lesson.
Unlock
Result
Key point
In call by reference, changes made to the formal parameter affect the actual parameter.……
Premium
This card is part of the premium lesson.
Unlock
Most important difference
Call by Value void test(int x) Call by Reference voi……
Premium
This card is part of the premium lesson.
Unlock
Comparison
Example comparison
Call by Value void test(int x) {……
Premium
This card is part of the premium lesson.
Unlock
VALUE = COPY REFERENCE = ORIGINAL அல்லது……
Premium
This card is part of the premium lesson.
Unlock
CALL BY ADDRESS / POINTER
C++-ல் address-ஐ pointer மூலம் function-க்கு pass ……
Premium
This card is part of the premium lesson.
Unlock
Function: void change(int *x) { } Call: cha……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Line explanation
Variable: int a = 10; Suppose: a value = 10 a address = 1000 Call: change(&a); &a means: 1000 Address functio……
Premium
This card is part of the premium lesson.
Unlock
& and * difference
Pointers புரிந்துகொள்ள இரண்டு symbols முக்கியம். & Address-of oper……
Premium
This card is part of the premium lesson.
Unlock
Pointer flow
a = 10 Address of a = 1000 | ↓ change(&a) | ……
Premium
This card is part of the premium lesson.
Unlock
Comparison
Three methods comparison
Very important example - swapping
Parameter passing கேள்விகளில் மிகவும் common example: Swap two numbers WRONG SWAP USING CALL BY VALUE #i……
Premium
This card is part of the premium lesson.
Unlock
Swap function உள்ளே நடந்தாலும……
Premium
This card is part of the premium lesson.
Unlock
CORRECT SWAP USING CALL BY REFERENCE
Why reference swap works?
Initially: a = 10 b = 20 References: x → a y → b Then: temp = x; temp =……
Premium
This card is part of the premium lesson.
Unlock
Swap using pointer
#include using namespace std; void swapNumbers(int *x, int *y) { in……
Premium
This card is part of the premium lesson.
Unlock
Pass by const reference
C++-ல் ஒரு large object-ஐ copy செய்யாமல் function-க்கு pass செய……
Premium
This card is part of the premium lesson.
Unlock
Example
இங்கு: unnecessary string copy இல்லை original ……
Premium
This card is part of the premium lesson.
Unlock
Example
#include #include using namesp……
Premium
This card is part of the premium lesson.
Unlock
Why const reference?
Suppose: string text = "Very large data..."; Call by value: void show(string text) copy உருவாகலாம……
Premium
This card is part of the premium lesson.
Unlock
Default parameters
Parameter passing topic-இல் related important concept: Def……
Premium
This card is part of the premium lesson.
Unlock
Example
Premium
This card is part of the premium lesson.
Unlock
Call: display(); argument இல்……
Premium
This card is part of the premium lesson.
Unlock
Another default parameter example
void add(int a, int b = 5) { ……
Premium
This card is part of the premium lesson.
Unlock
Important default argument rule
Default arguments generally rightmost parameters-லிருந்து கொடுக்க வேண்டும். Correct: void fun(int a, int b = ……
Premium
This card is part of the premium lesson.
Unlock
Parameter count
Function declaration: void add(int a, int b) என்றால் normally two arguments ……
Premium
This card is part of the premium lesson.
Unlock
Parameter order
Parameter order முக்கியம்.…
Premium
This card is part of the premium lesson.
Unlock
Example
Call: subtract(20, 5); Mappin……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
So arguments position-based m……
Premium
This card is part of the premium lesson.
Unlock
Type matching
Formal parameter: void show(int x) Call: show……
Premium
This card is part of the premium lesson.
Unlock
10.8 double value int parameter-க்கு conversion ஆகலாம்.
Result may become: 10 அதனால் ……
Premium
This card is part of the premium lesson.
Unlock
Value parameter lifetime
Call by value: void test(int x) { } x function enter ஆகும்போது உருவாகிறது. Function மு……
Premium
This card is part of the premium lesson.
Unlock
Reference parameter important point
void change(int &x) இங்கு x new ……
Premium
This card is part of the premium lesson.
Unlock
Example
Premium
This card is part of the premium lesson.
Unlock
a and x ↓ same object So: x =……
Premium
This card is part of the premium lesson.
Unlock
Common error 1
Call by value பயன்படுத்தி original value change ஆகும் என்று நினை……
Premium
This card is part of the premium lesson.
Unlock
Common error 2
Reference syntax தவறு: Wrong: ……
Premium
This card is part of the premium lesson.
Unlock
Common error 3
Pointer function-ஐ wrong call செய்வது. Function: void c……
Premium
This card is part of the premium lesson.
Unlock
Common error 4
Dereference செய்யாமல் pointer variable-க்கு value assign……
Premium
This card is part of the premium lesson.
Unlock
Common error 5
Reference parameter-க்கு call செய்யும்போது & எழுதுவது. Function: void change(int &x) Correct call: change……
Premium
This card is part of the premium lesson.
Unlock
Reference → & in definition P……
Premium
This card is part of the premium lesson.
Unlock
Call by Value void fun(int x) Copy. Call by Reference void f……
Premium
This card is part of the premium lesson.
Unlock
When to use which?
Use Call by Value when: Original data change ஆகக்கூடாது Data is small Independent copy வேண்டும் int square(in……
Premium
This card is part of the premium lesson.
Unlock
In which parameter passing method does ……
Premium
This card is part of the premium lesson.
Unlock
Which symbol is used for refe……
Premium
This card is part of the premium lesson.
Unlock
Consider: void fun(int x) { x……
Premium
This card is part of the premium lesson.
Unlock
Question 4
void fun(int &x) { x = 20; } ……
Premium
This card is part of the premium lesson.
Unlock
Actual values supplied in a f……
Premium
This card is part of the premium lesson.
Unlock
Parameters written in a funct……
Premium
This card is part of the premium lesson.
Unlock
Which uses a copy of the actu……
Premium
This card is part of the premium lesson.
Unlock
Which can directly modify the……
Premium
This card is part of the premium lesson.
Unlock
Which declaration represents ……
Premium
This card is part of the premium lesson.
Unlock
Is C++ really "call by reference"? In practical C++ terminology: void fun(int &x) is called pass by ……
Premium
This card is part of the premium lesson.
Unlock
Why is pass by const referenc……
Premium
This card is part of the premium lesson.
Unlock
Example
void display(const string &s)……
Premium
This card is part of the premium lesson.
Unlock
1. Avoids copying large object 2. ……
Premium
This card is part of the premium lesson.
Unlock
Remember this: int x ↓ VALUE ↓ COPY ↓ ORIGINAL SAFE int &x……
Premium
This card is part of the premium lesson.
Unlock
Exam short note
Parameter passing என்பது calling function-லிருந்து called function-க்கு arguments அனுப்பும் mechanism ஆகும். ……
Premium
This card is part of the premium lesson.
Unlock
Parameter Passing | ├── Actual Parameter | ↓ |……
Premium
This card is part of the premium lesson.
Unlock
1. Pass by Value ↓ Copy ↓ Original unchanged 2. Pass by Reference ↓ ……
Premium
This card is part of the premium lesson.
Unlock
One-line memory: Value = Copy……
Premium
This card is part of the premium lesson.
Unlock