Explain default arguments, C/C++ Programming

Assignment Help:

Default Arguments

A default argument is a value that is automatically assigned to a formal variable, if the actual argument from the function call is omitted.

e.g.

void drawbox( int x1=1, int y1=1, int x2=25, int y2=80,

 int color=7);                                                // Prototype

 

  void main ( void )

 {

 drawbox(10,1,25,80,14); // parameters passed

 drawbox();   // uses default arguments        

}     

void drawbox( int x1, int y1, int x2, int y2,

          int color)

{

// Body of the function

                   }

 Function drawbox() draws a box around the edges of the coordinates passed as parameters. If these parameters are omitted, then the default values, as given in the declaration are passed.

 


Related Discussions:- Explain default arguments

Change to palindrome, A palindrome is a string that reads the same from the...

A palindrome is a string that reads the same from the both the ends. Given a string S convert it to a palindrome by doing character replacement. Your takes is to convert S to palin

Oop, define a class for student

define a class for student

Operation on string - c ++ program, Operation on String - C ++ Program: ...

Operation on String - C ++ Program: Write a program to define operations on string in c++. class String {    char *char_ptr;   // pointer to string contents    int le

Operations on strings, 1 Aims The main purpose of the assignment is to ...

1 Aims The main purpose of the assignment is to let you practice the following programming techniques: perform operations on pointers to basic and more complex types;

What is union, What is Union? Intimately associated with the structure ...

What is Union? Intimately associated with the structure is the union which as well contains multiple members. Unlike a structure but the members of a union share the same stora

Webcam driver static library or dll required for windows, Webcam Driver sta...

Webcam Driver static library or DLL required for Windows I want a .dll or .lib file using which i will take a snapshot from the webcam and it can't turn on the webcam LED while

Dynamic constructor, dynamic initialization of object using constructor in ...

dynamic initialization of object using constructor in C++

Describe "this" pointer?, It is a pointer accessible only in the member fun...

It is a pointer accessible only in the member functions of a struct, class or union type. It points to the object for which the member function is called. Static member functions d

C++, write a C++ program that performs the following tasks 1. prompts the u...

write a C++ program that performs the following tasks 1. prompts the user to enter two numbers 2. displays the divisors of each number and store the divisors of number 1 in A and t

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd