Skip to content

Commit a393820

Browse files
committed
Added Function Overloading
Signed-off-by: Satya Sundar Sahu <[email protected]>
1 parent 343afe5 commit a393820

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

cpp_note

+41-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ Topic Cover:
88

99
https://www.youtube.com/watch?v=pX6LufLso2M&list=PL0gIV7t6l2iIsR55zsSgeiOw9Bd_IUTbY&index=10
1010

11-
lecture goibg to start: 9,
11+
https://www.youtube.com/watch?v=GtsBZ5e1-cE&list=PL0gIV7t6l2iIsR55zsSgeiOw9Bd_IUTbY&index=12
12+
13+
https://www.youtube.com/watch?v=N4gpIkQKUbc&list=PL0gIV7t6l2iIsR55zsSgeiOw9Bd_IUTbY&index=15
14+
15+
lecture goibg to start: 9, 10, 12, 14,
1216

1317
//////////////////////////////////////////////////////////////////////////////////////////
1418

@@ -21,3 +25,39 @@ Define vector
2125
Array size is fixed and decide at compile time. But vector size is not fixed size it can be change with "arr.resize(20)".
2226

2327
2> Inline function can not be recursive.
28+
29+
Reference:
30+
-----------
31+
1> This is the alias of a variable.
32+
int a = 10; Below Both the case a and b address is same.
33+
int &b = a;
34+
35+
int &c; => Error becz there is no varibale for alias.
36+
37+
2> int &j = 6 ==> Error becz we can not refer to constant But we can refer to const int &j = 6
38+
39+
3> int &j = i + j ===> Error above resons const int &j = i + j
40+
41+
4> NEVER EVER RETURN LOCAL VARIABLE REFERENCE.
42+
43+
Default Paramter and Function Overloading:
44+
-------------------------------------------
45+
1> If we are not pasing any parameter at the time of call system will take default value mention in function declaration.
46+
47+
2> i> All the parameter right of default parameter should be defaulted.
48+
Ex: void foo(int, double = 1, char *) // Error becz char * shuld be defaulted
49+
void foo(int, double = 1, char * = NULL) //OK
50+
ii> Default argument can not be redefind.
51+
Ex: void foo(int, double = 1, char * = NULL) //OK
52+
void foo(int, double = 2, char * = NULL) //Error redefind
53+
iii> All non-default parameter should mention at the time of function call.
54+
55+
3> Always use default parameter in headerfile.
56+
57+
4> Function Overloading is called static Polymerprisim
58+
59+
5> Function Binding happen at compile time in function Overloading.
60+
61+
6> In Function Overloading different return type in overloading function is not possible.
62+
63+
7>

func.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int foo(int a = 2+5)
1212

1313
int main()
1414
{
15-
int a = 0, ret;
15+
int a = 12, ret;
1616
cout << "a = " << a << " &a = " << &a << endl;
1717
ret = foo(a);
1818
cout << "a = " << a << " &a = " << &a << "\nret = "<< ret <<endl;

0 commit comments

Comments
 (0)