File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Learn_CPP_Programming_Deep_Dive/Section 10 Functions/Function_pointers Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ using namespace std ;
4
+
5
+ void display ()
6
+ {
7
+ cout<<" It is Friday evening. Weekend is coming!!" <<endl;
8
+ }
9
+
10
+ int max (int a, int b)
11
+ {
12
+ cout<<" I am in max function" <<endl;
13
+ return a > b ? a : b ;
14
+ }
15
+
16
+ int min (int a, int b)
17
+ {
18
+ cout<<" I am in the min function" <<endl;
19
+ return a < b ? a : b ;
20
+ }
21
+
22
+
23
+ int main (void )
24
+ {
25
+ void (*fp) () ; // declaration
26
+ fp = display; // initialization
27
+ (*fp)(); // usage of the function pointer
28
+
29
+
30
+ int (*fp1)(int , int ); // declaration of function pointers returning other than void and that take parameters
31
+ fp1 = max; // initialization
32
+ (*fp1)(10 ,5 ); // usage
33
+
34
+ fp1 = min;
35
+ (*fp1)(10 ,5 ); // usage
36
+
37
+ return 0 ;
38
+ }
You can’t perform that action at this time.
0 commit comments