JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: c++ language in hindi

const member function c++ in hindi , what is constant member function in c++ language

what is constant member function in c++ language , const member function c++ in hindi :-
इससे पहले के article मे const के basic को discuss किया तह अब इस article मे const के बारे और कुछ पॉइंट्स को discuss करेगा |
c++ मे , const keyword का use किसी storage को alter करने के लिए किया जाता है |जहा पर global variable का linking external होता है लेकिन const global variable का linking internal होता है |  c++ मे जिस पारकर static specifier को use किया जाता है उसी प्रकार global const variable को use किया जाता है |
उदाहरन के लिए
#include<iostream.h>
#include<conio>h>
const int a= 16;
int main() {
cout<<“data : “<<a;
getch();
}
इस उदाहरन मे , a एक global const variable है जिसकी value 16 है ये variable एक static variable की तरह कार्य करता है | इसके value पुरे प्रोग्राम मे constant होता है |
c++ constant variable की value को change करने के लिए simple method होती है | उद्धरण के लिए अगर किसी constant value को header file मे declare किया जाता है | इसे कही जगह use किया जा सकता है |  लेकिन इस header file को preprocessor के बाद include किया जाता है | तभी इसे variable को use किया जा सकता है |सभी सौद्र्स file मे global variable को define किया जाता है  |
const int a= 10 ;
const char * name = ” parth “;
अगर global variable को  रेगुलर variable से external linkage होता है | लेकिन इसमें error होता है | जब किसी global variable को एक file मे define किया जाता है  तब केवल इस file मे ही global variable को use किया जाता है | लेकिन किसी दूसरी file मे , इस variable को use करने के लिए extern keyword को use किया जाता है |
इसका उदाहरन है ;
file 1 मे
const int a= 1;
char char * name = parth;
file 2 मे ,
#include<iostream.h>
#include<conio>h>
#include file1 ;
int main() {
cout<<“data : “<<a;
cout<<“name :”<<*name ;
cout<<“Adddress :”<<&name ;
getch();
}
उपर दिए गये उदाहरनो मे ग्लोबल variable को file 2 मे use किया जाता है | इसमें error आता है | क्योकि file 1 और file 2 मे const variable को access नहीं किया जा सकता है |
इसके लिए extern को use किया जाता है |
file 1 मे
extern const int a= 1;
extern char char * name = parth;
file 2 मे ,
#include<iostream.h>
#include<conio>h>
#include file1 ;
int main() {
cout<<“data : “<<a;
cout<<“name :”<<*name ;
cout<<“Adddress :”<<&name ;
getch();
}
इस उदाहरनो मे const variable को external linking को बनाया गया है इसके लिए extern keyword को use किया जाता है | external linking के द्वारा इन variable  को file 2 मे  use किक्या जा सकता है |
variable मे linking को बजाय जाता है | इसके अलावा function के साथ linking को use किया जा सकता है |
Function linking
c++ मे , एक function के अन्दर दुसरे function को define नहीं किया जा सकता है | in function का scope static storage होता है इन function का life cycle जब तक होता है तब प्रोग्राम की running होगा | जब किसी function को किसी दुसरे function के अन्दर को define किया जाता है तब in function को extern keyword के अथ define किया जाता है | लेकिन यव ऑप्शनल है |
static keyword से function का scope static होता है | इसका linking इंटरनल होता है |
इसका उदाहरन होता है :
#include<iostream.h>
#include<conio>h>
static void add(int , int );
int main() {
int a, b;
cout<<“Enter values :”<<endl;
cin>>a>>b;
add(a,b);
getch();
}
static void add(int e , int f)
{
int c= e+f;
cout<<“Output :”<<c;
}
इस उदहारण मे , function केवल इस file मे use हो सकता है | लेकिन जब किसी function को external के साथ define किया जाता है तब इस function को किसी file मे
c++ मे , const keyword का use किसी memory location को  fixed करने के लिए किया जाता है |जहा पर function का linking external होता है लेकिन const global function  का linking internal होता है |
उदाहरन के लिए
#include<iostream.h>
#include<conio>h>
const print(char a);
int main() {
cout<<“data : “<<a;
getch();
}
इस उदाहरन मे , print एक global const function  है जिसमे line को print किया जाता  है ये function एक static function की तरह कार्य करता है | इसके value पुरे प्रोग्राम मे use किया जा सकता  है |
c++ constant function  की scope को change करने के लिए linking को change किया जाता है  | उदाहरन  के लिए अगर किसी function  को header file मे declare किया जाता है | इसे कही जगह use किया जा सकता है |  लेकिन इस header file को pre processor के बाद include किया जाता है | तभी इसे function  को use किया जा सकता है |
int add(int , int );
int check( int number );
अगर global function को  रेगुलर function  से external linkage होता है | लेकिन इसमें error होता है | जब किसी global function  को एक file मे define किया जाता है  तब केवल इस file मे ही global function  को use किया जाता है | लेकिन किसी दूसरी file मे , इस function  को use करने के लिए extern keyword को use किया जाता है |
इस article मे , const  को discuss किया है अब आगे के article मे c++ के कुछ और advance topic को discuss करेगे |
Sbistudy

Recent Posts

Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic

Question Tag Definition • A question tag is a small question at the end of a…

2 weeks ago

Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)

Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…

2 weeks ago

Report Writing examples in english grammer How to Write Reports explain Exercise

Report Writing • How to Write Reports • Just as no definite rules can be laid down…

2 weeks ago

Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th

Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…

2 weeks ago

विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features

continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…

2 weeks ago

भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC

भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…

2 weeks 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