Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Default Arguments in User-defined Functions of Programming in CPP
1840 Views
Usage 
Default Arguments can be used to pass default values to arguments when values are undefined in main function.
Example
#include <iostream>
using namespace std;

void display(int = 4);

int main()
{
    cout<<"No values passed:\n";
    display();
   
    cout<<"value passed:\n";
    display(5);
  

    return 0;
}

void display(int a){

        cout<<"the value of a"<<a;
    }
    cout<<endl;
}
Output 
No values passed:
The value of a=4

value passed
The value of a=5
Next Topics
Next lessons of current book.
Math Library Functions of Programming in CPP
Math Library Functions of Programming in CPP
Math Library Functions of Programming in CPP
Math Library Functions of Programming in CPP
Math Library Functions of Programming in CPP
Previous Topics
Previous lessons of current book.
User-defined Functions of Programming in CPP
User-defined Functions of Programming in CPP
User-defined Functions of Programming in CPP
Best Lessons of "Programming in CPP"
Top lessons which are viewed more times.
String Class in CPP of Programming in CPP
Math Library Functions of Programming in CPP
Classes and Objects in CPP of Programming in CPP
String Class in CPP of Programming in CPP
User-defined Functions of Programming in CPP
Math Library Functions of Programming in CPP
String Class in CPP of Programming in CPP
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details