MEMBER FUNCTION in c++ language in hindi , program example source code with explanation

program example source code with explanation , MEMBER FUNCTION in c++ language in hindi :-
इससे पहले के article मे class और object के basic को discuss किया तरह अब इस article मे class और object के advance method को discuss करेगे | जो की c++ प्रोग्रामर के बहुत जरुरी स्कील होता है |
 
Function member 
c++ क्लास मे variable को function को define किया जाता है | जिन function को c++ class मे define किया जाता है use function member कहते है | इसे declare कर्ण एक एलिए scope resolution operator को use किया जाता है | अनहि तक हमने केवल एसे function के उदाहरन को discuss किया है जिसे class मे ही declare किया जाता है | लेकिन अगर class मे function के सख्या बहुत जयादा होती है तब इसे क्लास्स के बहार declare किया जा सकता है | function को नार्मल function की तरह define किया जा सकता है | जिसमे function का हेडर होता है और फुन्क्टियो n की बोदे होती है |
उदाहरन के लिए
function_type function_name
{
function_body ;
}
यहा पर
function_type : यहाँ पर function मे से return किये गये value के type को define करता है |
function_name : ये function के name को define करता है |
function _body : ये function मे perform किये गये task को डेफिन करता है |
लेकिन class member को define करने के लिए निन्म changes होते है :-
1.जब class member को क्लास scope से बहार डेफिन किया जाता है तब इसे scope resolution (::)के साथ define किया जता है |
2.class method private function को भी access किया जा सकता है |
लेकिन निन्म points को consider कियाजाता है |
1.function header मे scope resolution (::) को use किया जाता है जो की function की class से connectivity को define करता है | उदाहरन के लिए class math मे एक function square है इसे class scope से बहार define करने के लिए निन्म syntax होता है :-
math :: square ()
इस syntax से define होता है की square () एक member function है | इसके अलावा ये भी define करता है इस function name square () को किसी दुसरे class मे function name की तरह use किया जा सकता है | जैसे
calculator :: square ()
scope resolution operator का use क्लास function के method को indentify करने के लिए किया जाता है | यह पर square () का class scope है | sqaure () को scope resolution के बिना use किया सकता है |
अतः function को define कर्ण एके लिए दो method को use किया जा सकता है |  पहले method मे class का पूरा name को function header मे scope resolution  के साथ use किया जा सकता है | math :: square () इसे qualify name कहते है | दुसरे method मे class name के abbreviation को use किया जाता है जिसे class scope के लिए use किया जाता है |
2.इस method मे class के private function member को भी use किया जा सकता है | उदाहरन के लिए
cout<<“name :”<<name ;
cout<<“price “<<price ;
cout<<“year :”<<year ;
इस उदाहरन मे show () मे class के private variable price और year को use किया जा सकता है |अगर किसी non member function ने इस private variable को use करने के लिए use किया जाता है तब compiler मे error आ जाता है |
दोनों characteristic को ध्यान मे रख के class function को declare किया जा सक्यता है | इस method का use दो अलग अलग function मे use किया जासकता है | या एक ही file मे भी use किया सकता है |
उदाहरन के लिए
#include<iostream>
vopid stock ::first_biding(const * char company_name  , int num , double price )
{
std :: strcpy (company,company_name,50 );
company[50]=’\0′;
if(num<0)
{
std::cerr<<“share can not be negetive “;
         << we set share equal to ‘0’ “<<endl;
share = 0 ;
}
else
share = num ;
share_price = price ;
total ();
}
vopid stock ::buy( int num , double price )
{
if(num<0)
{
std::cerr<<“share ourchase can not be negetive “;
         << Transtion denied  “<<endl;
}
else
share + = num ;
share_price = price ;
total ();
}
}
vopid stock ::sell( int num , double price )
{
if(num<0)
{
std::cerr<<“share sell can not be negetive “;
         << Transtion denied  “<<endl;
}
else if(num > share)
{
std::cerr<<“share sell can not higehr than  contain share “;
         << Transtion denied  “<<endl;
}
else
share – = num ;
share_price = price ;
total ();
}
}
void stock :: update (double price )
{
share_price = price ;
total ();
}
void stock :: update ( )
{
void std :: cout;
void std :: endl;
cout<<“Company Name : << company;
cout<<“share :”<<share ;
cout<<“”Total Worth :”<<share_price ;
}
इस उदाहरन मे किसी कंपनी के शेयर को manage करने के लिए छोटा सा प्रोजेक्ट है जिसमे 5 function है :
1.update () : इसमें कंपनी के शेयर price को update किया जाता है |
2.show () ; इसमें कम्पनी की detail जैसे name , शेयर , worth को display किया जाता है |
3.buy() : इसमें compnay के द्वारा purchase किये गये शेयर को को update किया जाता है |
4.sell() : इसमें कम्पनी के द्वारा sell किया गये शेयर को update किया जाता है |
5.first_biding() : इसमें कम्पनी के initail value को manage किया जाता है |
इस article मे class के मेबर function को discuss किया है अब age के article मे member function के उदाहरनो को डिस्कस करेगे |