C++ : User Define function Types in hindi , how many type of user define functions in c++ language

how many type of user define functions in c++ language , C++ : User Define function Types in hindi :-
इससे पहले के article मे function का basic structure , return type statement और argument pass को discuss किया गया है \ अब इस article मे function के type को discuss  करेगे |
User define function के type
किसी User define function मे argument और return statement का अहम् भूमिका होती है अतः argument और return statement के आधार User define function को चार भागो मे divined किया है |
1.User define function with no argument and no return type
2.User define function with no argument and return type
3.User define function with argument and return type
4.User define function with no argument and no return type
इन सभी types को इस article मे अच्छी तरह से discuss करेगे |
1. User define function with no argument and no return type
जब किसी User define function मे कोई भी argument को function call statement मे pass नहीं किया जाता है और User define function की definition मे कोई भी return statement नहीं होती है | तब User define function को no argument and no return value type का होता है |
इस type मे main() function मे केवल function को call किया जाता है | और बाकि के operation जैसे यूजर द्वारा input लेना , operation perform करना , आउटपुट display करना आदि function डेफिनिशन मे declare होता है |
इसका उदाहरन होता है :
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
void add( );
int main()
{
// function call
add(n1, n2);
getch();
}
// Function definition
void add( )
{
int n1, n2 ;
cout<<“Enter value1 : “;
cin >> n1;
cout<<“Enter value2 : “;
cin >> n2;
int output;
output = n1 + n2 ;
cout<<“Output : “<<output;
}
इस उदाहरन मे , function prototype मे निन्म पॉइंट्स consider किया जा सकता है :
function prototype मे function का type void है अतः function defition से कोई value return नहीं होती है |
function declartion मे कोई भी argument pass नहीं होता है |
main() function मे केवल function को call किया जाता है |
function definition मे , यूजर द्वारा value को input किया गया है | in value को add करके variable output मे assign किया जाता है |
और आउटपुट की value को display किया जाता है |
इसका आउटपुट होगा :
Enter value1 : 12
Enter value2 : 24
Output : 36
2. User define function with no argument and return type
जब किसी User define function मे कोई भी argument को function call statement मे pass नहीं किया जाता है और User define function की definition मे  return statement होता  है | तब User define function को no argument and return value type का होता है |
इस type मे main() function मे केवल function को call किया जाता है | function द्वारा return की value को variable मे assign कर ली जाती है | और बाकि के operation जैसे यूजर द्वारा input लेना , main operation perform करना  आदि function डेफिनिशन मे होता है |
इसका उदाहरन होता है :
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
int  add( );
int main()
{
int sum ;
// function call
sum = add();
cout<<“Output : “<<sum ;
getch();
}
// Function definition
int add( )
{
int n1, n2 ;
cout<<“Enter value1 : “;
cin >> n1;
cout<<“Enter value2 : “;
cin >> n2;
int output;
output = n1 + n2;
return output;
}
इस उदाहरन मे , function prototype मे निन्म पॉइंट्स consider किया जा सकता है :
function prototype मे function का type int है अतः function definition से return होनी वाली value का type integer है |
function declaration मे कोई भी argument pass नहीं होता है |
main() function मे केवल function को call किया जाता है | और function add () द्वारा return की गयी value को variable sum मे assign किया जाता है |
function definition मे , यूजर द्वारा value को input किया गया है | इन value को add करके variable output मे assign किया जाता है |
और आउटपुट की value को return किया जाता है |
इसका आउटपुट होगा :
Enter value1 : 35
Enter value2 : 24
Output : 59
3. User define function with  argument and return type
जब किसी User define function मे  argument को function call statement मे pass किया जाता है और User define function की definition मे  return statement होता  है | तब User define function को  argument and return value type का होता है |
इस type मे सभी operation जैसे यूजर द्वारा input लेना , function call और आउटपुट को print करना आदि main() function मे होता है | function definition मे केवल function मे perform होने वाले मुख्य operation के लॉजिक को लिखा जाता है |
इसका उदाहरन होता है :
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
int  add( int , int );
int main()
{
int sum ;
int n1, n2 ;
cout<<“Enter value1 : “;
cin >> n1;
cout<<“Enter value2 : “;
cin >> n2;
// function call
sum = add(n1 ,n2 );
cout<<“Output : “<<sum ;
getch();
}
// Function definition
int add( int a, int b )
{
int output;
output = a + b;
return output;
}
इस उदाहरन मे , function prototype मे निन्म पॉइंट्स consider किया जा सकता है :
function prototype मे function का type int है अतः function definition से return होनी वाली value का type integer है |
function declaration मे  argument pass होता है | अतः (int , int ) का मतलब मे function दो arguments pass होता है और इसका type integer होता है |
main() function मे , यूजर द्वारा data को input किया जाता है और बाद मे  function को call किया जाता है |
function add () द्वारा return की गयी value को variable sum मे assign किया जाता है |
function definition मे ,  इन value को add करके variable output मे assign किया जाता है |
और आउटपुट की value को return किया जाता है |
इसका आउटपुट होगा :
Enter value1 : 70
Enter value2 : 70
Output : 140
3. User define function with  argument and no return type
जब किसी User define function मे  argument को function call statement मे pass किया जाता है और User define function की definition मे  कोई भी  return statement नहीं होता  है | तब User define function को  argument and no return value type का होता है |
इस type मे सभी operation जैसे यूजर द्वारा input लेना , function call आदि main() function मे होता है | function defition मे केवल function मे perform होने वाले मुख्य operation के लॉजिक  और इस operation से प्राप्त value को display किया  जाता है |
इसका उदाहरन होता है :
#include <iostream>
#include<conio.h>
using namespace std;
// Function prototype (declaration)
void add( int , int );
int main()
{
int n1, n2 ;
cout<<“Enter value1 : “;
cin >> n1;
cout<<“Enter value2 : “;
cin >> n2;
// function call
add(n1 , n2 );
getch();
}
// Function definition
void add( int a, int b )
{
int output;
output = a + b;
cout<<“Output : “<<output ;
}
इस उदाहरन मे , function prototype मे निन्म पॉइंट्स consider किया जा सकता है :
function prototype मे function का type void  है अतः function definition से कोई भी value return नहीं हो रही  है |
function declaration मे  argument pass होता है | अतः (int , int ) का मतलब मे function दो arguments pass होता है और इसका type integer होता है |
main() function मे , यूजर द्वारा data को input किया जाता है और बाद मे  function को call किया जाता है |
function definition मे ,  इन value को add करके variable output मे assign किया जाता है |
और आउटपुट की value को display करे दिया जाता है |
इसका आउटपुट होगा :
Enter value1 : 90
Enter value2 : 60
Output : 150
इस article मे , function के type को discuss किया गया है अब आगे के article मे function से related advance topic जैसे garbage handling आदि को discuss करेगे |