1 / 4

Default Argument

Default Argument. Default Argument. C++ provides to define default argument value for functions In function def the default values are given

yama
Download Presentation

Default Argument

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Default Argument

  2. Default Argument C++ provides to define default argument value for functions In function def the default values are given Whenever a call is made to a function without specifying an argument, then the progwill automatically assign values to the parameters from the default arguments specified in fun def eg Void function(int a, int b, int c=100) {.. } when we calling the fun with 2 arguments then value of c will be 100 function(1,2)// missing arg Here value of a 1 b 2 and c100 (default value)

  3. Default Argument If the above function is called as Function(1,2,3);// no missing arg Then values of a1, b2 and c3 In default argument we can assign default values from right arg to left arg Cannot provide default value to a particulate argument in the middle Ie Function(inta,intb,int c=100)valid Function (inta,int b=200,int c=100) valid Function(inta,int b=200,int c)invalid

  4. Default Argument Questions Addition of two nos, three nos and four nos

More Related