Presentation is loading. Please wait.

Presentation is loading. Please wait.

D.L. Patel Institute of management & Technology (M.C.A. College),”Vidyanagri” Name: Bhatt Nishant D. Subject: OOP (object oriented programming language)

Similar presentations


Presentation on theme: "D.L. Patel Institute of management & Technology (M.C.A. College),”Vidyanagri” Name: Bhatt Nishant D. Subject: OOP (object oriented programming language)"— Presentation transcript:

1 D.L. Patel Institute of management & Technology (M.C.A. College),”Vidyanagri” Name: Bhatt Nishant D. Subject: OOP (object oriented programming language) Subject Code: 620003

2 FUNCTION Unit No - 2

3 Contents Function 1. Introduction, 2. The inline function, 3. Function Overloading 4. Default Arguments to the function, 5. Functions with object as parameters, 6. Call by reference and return by reference, 7. Prototyping and Overloading, 8. Friend functions,

4 Introduction We know that function play an important role in C program development. Dividing a program into Function is one of the major principles of top-down, structure programming. Another Advantage of using function is that it is possible to reduce the size of a program by calling and using them at different places in the program.

5 Simple Function Our first Example Demonstrates a Simple Function whose purpose is to print a line of 45 astrisks, The example Program generates a table, and lines of astriks are used to make the table more readable. Here`s the listing for TABLE: ( Conti……….. ) Simple Function Program

6 Simple function Void show(); // Function declaration main() { ……………. show(); // Function call ……………. } Void show() // Function Defination { ……………. ……………. // Function body ……………. } -> syntex

7 inline function -> we mentioned that function save memory space because all the calls to the function cause the same code to be executed; the function body need not duplicated in memory. ->when the complier sees a function call, it normally generates a jump to function. To save execution time in short function, you may elect to put the code in the function body directly inline with the code in the calling program. -> purpose ( Conti…… )

8 inline function -> That is, each time there`s a function call in the source file, the actual code from the function is inserted of a jump to the function. -> The Differeance between a function and inline code show in figure.... -> purpose ( Conti…… )

9 inline function -> figure ~~~~~~~~ Func1(); ~~~~~~~~ Func1(); ~~~~~~~~ Func1(); ~~~~~~~~ main() ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ main() func1() a) Repeated code placed in function ~~~~~~~~ b) Repeated code placed inline fun. [ Function versus Inline code ….. ]

10 inline function -> ExampleExample


Download ppt "D.L. Patel Institute of management & Technology (M.C.A. College),”Vidyanagri” Name: Bhatt Nishant D. Subject: OOP (object oriented programming language)"

Similar presentations


Ads by Google