Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Functions in C+       +    Presented by Sachin         Sharma
Function Overloading• C++ enables several functions of the  same name to be defined, as long as  these functions have diff...
Example To Use The concept of function                  overloading# include<iostream.h># include<conio.h>void area (float...
OutputEnter value of r1:2Enter value of l1:4Enter value of b1:6Area of the circle isArea = 12.56Area of the rectangle isAr...
Inline Functions in C++• Whenever we call a function, control jump to  function and come back to caller program when  exec...
Example to demonstrate inline functions#include<iostream.h>#include<conio.h>inline float mul (float x, float y){       ret...
Output121.2281.25713
Thank You
Prochain SlideShare
Chargement dans…5
×

Functions in C++

10 906 vues

Publié le

Publié dans : Formation
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE Format, ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici

Functions in C++

  1. 1. Functions in C+ + Presented by Sachin Sharma
  2. 2. Function Overloading• C++ enables several functions of the same name to be defined, as long as these functions have different sets of parameters (at least as far as their types are concerned). This capability is called function overloading.
  3. 3. Example To Use The concept of function overloading# include<iostream.h># include<conio.h>void area (float r);void area (float l, float b);void main(){ float r1, l1, b1;clrscr(); cout<<“ Enter value of r1: ”<<endl; cin>>r1; cout<<“ Enter value of l1: ”<<endl; cin>>l1; cout<<“ Enter value of b1: ”<<endl; cin>>b1;cout<<“ Area of the circle is “<<endl;area (r1);cout<<“ Area of the rectangle is “<<endl;area (l1, b1);}void area (float r){ float a = 3.14*r*r; cout<<“ Area = “<<a<<endl;}void area (){ float a1 = l*b;
  4. 4. OutputEnter value of r1:2Enter value of l1:4Enter value of b1:6Area of the circle isArea = 12.56Area of the rectangle isArea = 24
  5. 5. Inline Functions in C++• Whenever we call a function, control jump to function and come back to caller program when execution of function is completed. This process takes a lot of time. C++ provides a solution of this problem, that is inline function. With inline function, the compiler replaces the function call statement with the function code itself (process called expansion) and then compiles the entire code. Thus, with inline functions, the compiler does not have to jump to another location to execute the function, and then jump back as the code of the called function is already available to the calling program.
  6. 6. Example to demonstrate inline functions#include<iostream.h>#include<conio.h>inline float mul (float x, float y){ return (x*y);}inline double div (double p, double q){ return (p/q);}int main(){ float a = 12.345; float b = 9.82; clrscr();cout<<mul (a,b)<<endl;cout<<div (a,b)<<endl;return 0;}
  7. 7. Output121.2281.25713
  8. 8. Thank You

×