JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: c++ language in hindi

C++ : Default Parameter or Function Overloading in hindi , what is Default Parameter or Function Overloading c++ language

what is Default Parameter or Function Overloading c++ language , C++ : Default Parameter or Function Overloading in hindi :-
इससे पहले के article मे , function के basic structure , function के type और function के उदाहरानो को discuss किया | अब इस article मे function  overloading को discuss करेगे |Function Overloading
जब किसी दो या दो अधिक functions जिनका नाम same होता है लेकिन arguments अलग अलग होता है तब function overloading कहते है | इस article मे function overloading को discuss करेगे |
function किसी programming का एक छोटा सा segment होता है जो एक sepecfic कार्य के लिए बनाया जाता है | c++ language मे , दो सामान नाम वाले function को अलग अलग consider किया जाता है अगर इसमें pass argument की सख्या और type अलग अलग होती है |
दो function जिनका नाम सामान होता  है लेकिन argument की सख्या और type अलग अलग होता है उन functions को overload function कहते है | उदाहरन के लिए :
int add(){}
int add(int a ){}
int add(int a ,int b ){}
int add(int a , float b){}
इस उदहारण मे चार function होता है | उपर दिए गये function का नाम add( ) है लेकिन ये सभी function को अलग अलग consider किया जाता है | overload function मे argument अलग अलग होना चाहिए लेकिन return statement का अलग होना complusy नहीं होना चाहिए | अतः निन्म function function overload function नहीं है :
int add(int){}
float add(int , int ) {}
इन उदहारण मे  int add(int){} और float add(int , int ) {} overload function नहीं है |क्योकि दोनों functions का return type अलग अलग होता है |
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
void print (int);
void print (float);
void print(double);
void  main()
{
int number ;
float number1;
float number2;
cout<<“Enter integer number : “;
cin >> number;
cout<<“Enter float number : “;
cin >> number1;
cout<<“Enter double number : “;
cin >> number2;
// Function call
print(number);
print(number1);
print(number2);
getch();
}
void print (int a)
{
cout<<“You enter integer”<<a;
}
void print ( float a)
{
cout<<“You enter float value “<<a;
}
void print (double a)
{
cout<<“You enter double value “<<a;
}
इस उदहारण मे  void print (int); , void print (float); और  void print(double); overload functions है इन सभीfunction का type void है लेकिन इसमें pass किये जाने वाली value का type अलग अलग होता है | in function मे return type सामान है |

function overloading का उदहारण :
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
float  RoundOff( int );
int  RoundOff(float);
void  main()
{
int number ;
float number1;
float number2;
cout<<“Enter integer number : “;
cin >> number;
cout<<“Enter float number : “;
cin >> number1;
cout<<“round off value of number :”<<RoundOff( number ) <<endl;
cout<<“round off value of number1 :”<<RoundOff( number1 ) <<endl;
getch();
}
int RoundOff(int a)
{
if(a<0)
a=-a;
return a;
}
float  RoundOff(int a)
{
if(a<0.0)
a=-a;
return a;
}
इस उदाहरन मे , float  RoundOff( int ); और  int  RoundOff(float); overload function है | इन function का return type और argument type दोनों  ही अलग अलग होता है |
पहले function मे integer type variable को pass किया जाता है | और दुसरे function मे float type value pass किया जाता है |

Default value
c++ language मे function parameter की default value को initial किया जा सकता है | एसे argument को default parameter कहते है |जब किसी argument को function मे call नहीं किया जाता है तब इन parameter को default parameter कहते है | default parameter को function prototype मे pass किया जाता है | इसका उदहारण निन्म है :-
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
void printline (int i =1 , char = ‘*’)
void  main()
{
int number ;
float number1;
cout<<“Enter integer number : “;
cin >> number;
cout<<“Enter float number : “;
cin >> number1;
printline ();
cout<<” You enter :”<<number<<endl;
printline(“#”);
cout<<“You enter :”<<number1<<endl;
printline(5,’$’);
getch();
}
void printline(int n , char c)
{
for(int i=0;i<n;i++)
{
cout<<c;
}
}
इसका आउटपुट होगा :
Enter integer number : 12
Enter float number : 12.22
*
You enter : 12
#
You enter : 12.22
$$$$$

इस उदहारण मे जब
printline() को call किया जाता है | तो इसमें कोई भी argument pass नहीं किया जाता है इसलिए इसमें default char = ‘*’ ओत int i= 1 को use किया जाता है |
और
printline(“#”) को call किया जाता है तो इसमें केवल एक argument को पास किया गया है इसलिए इसमें दुसरे argument की default value को consider किया जाता है |
और
printline(5,’$’); को call किया जाता है इसमें दोनों argument को पास किया जाता है |

default value को use करने के लिए निन्म rules को फॉलो किया जाता है :-
1.किसी default parameter को normal parameter से मिक्स नहीं किया जाता है |उदहारण के लिए
int add(int a , int b =3, int c );
ये उदाहरण error message देता है क्योकि default parameter ‘b’ को नार्मल parameter के बीच declare किया गया है |
2.अगर एक बार default parameter को देकाल्रे कर दिया जाता है तब उसके बाद सभी value को default parameter बनाना पड़ता है | उदाहरन के लिए
int add(int a=9 , int b =3, int c );
ये उदाहरन भी error message देता है क्योकि default parameter ‘b’ के बाद सभी parameter भी default होता है |

Sbistudy

Recent Posts

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

1 day ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

3 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

5 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

5 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

5 days ago

FOURIER SERIES OF SAWTOOTH WAVE in hindi आरादंती तरंग की फूरिये श्रेणी क्या है चित्र सहित

आरादंती तरंग की फूरिये श्रेणी क्या है चित्र सहित FOURIER SERIES OF SAWTOOTH WAVE in…

1 week ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now