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

CLASS SCOPE in c++ language in hindi , class scope impermanent , example code

इससे पहले के articles मे variable के scope को discuss किया था | ठीक उसी प्रकार class के scope को भी define किया जा सकता है | variable का मुख्य दो प्रकार scope होते है |
global : इस type के variable को पुरे code मे कही पर भी use किया जा सकता है |
local : इस type के  variable को केवल define scope मे ही use किया जा सकता है |function name केवल global scope होता है इसका कभी भी local scope नहीं होता है | क्योकि  function को कभी भी किसी भी जगह call किया जाता है | c++ लंगुअग एमई एक नए प्रकार के scope को define किया गया है |  जिसे class scope कहते है इस article मे class scope को ही discuss करेगे |

class scope

class scope को class के अंडर define किये गय name पर लागु किया जाता है | अगर class scope को variable memeber के साथ use किया जाता है तब memeber variable को class data memeber कहते है और जब  class scope को  memeber function के साथ use किया जाता है तब memeber function को class function memeber कहते है  | जिस भी member को class scope के साथ define किया जाता अहि use केवल class के अंदर ही use किया जा सकता है | इस प्रकार सामान memeber name को दो या दो से अधिक class मे define किया जा सकता है | क्योकि एक class memeber का scope तो class मे limit रहता है |

class scope impermanent

जब किसिस क्लास मे member function को define करने के लिए unadorned memeber name को use किया जाता है | इससे पहले के उदहारण मे sell () function मे set_total() को call किया जाता है | constructor name को call किया जाता है क्योकि इसका नाम class name के सामान होता है | इसके अलावा membership operator (.) या membership operator(->) और scope resolution operator (::) को use किया जाता है | इसके लिए code के typeपर निर्भर करता है | निन्म कोदेमै class scope को use किया गया है जिससे आप सभी को class scope implement करने के method को समजा जा सकता है :-
class ik
{
private :
int a;
public :
ik(int add= 12 )
{
a= add;
}
}
void dispaly ()const ;
}
void ik :: display ()
{
cout<<a<<endl;
}
int main()
{
ik*d = new ik ;
ik g = ik(56);
g.display();
d->display ();
getch();
}

इस code मे , variable a का scope class scope होता है | और इसके बाद function  को define किया जाता है | जिसमे use द्वारा input किये गये data को variable a मे assign किया जाता है |
इसके बाद display () function  को define किया जाता है जो की class ik का type का होता है | इसलिए class के variable ‘a’ को use किया जाता है |

उदाहरन 2
इस उदाहरन मे दो अलग अलग class को define किया गया है जिसमे number variable name को use किया गया है | इस number variable का scope class scope है इसलिए केवल class calculator मे use किया जाता है | और दुसरे class statics मे number[] array को define किया जाता है | जिससे टीम function मे implement किया जाता है |
#inclue<iostrem>
#include<conio>
using namespace std;
class calculator
{
private :
int  a,b;
private :
void add(int a , int b );
void sub(int a , int b );
void mul(int a , int b );
void div(int a , int b );
void display( int a , int b )
{
cout<<“Addition is “<<add(a,b)<<endl;
cout<<“Subtraction is “<<sub(a,b)<<endl;
cout<<“Multipliaction is “<<mul(a,b)<<endl;
cout<<“Division is “<<div(a,b)<<endl;
} ;  // close of class
calculator :: add(int a , int b ) {
return a+b;
}
calculator :: sub (int a , int b ) {
return a-b ;
}
calculator :: mul(int a , int b ) {
return a*b ;
}
calculator :: div(int a , int b ) {
return a/b ;
}
class satistic
{
int b  [12];
satistic (int * num)
{
b = num ;
public ::
void avg ()
{
int sum = sum + b [i] ;
}
int avg = sum / 12 ;
cout<<“Avgerage : ” <<avg ;
}
void main()
{
int num1 , num2 ;
cout<<“enter number 1 :”<<endl;
cin>>num1 ;
cout<<“enter number 2 :”<<endl;
cin>>num2 ;
ca.display(num1 , num2) ;
int a[12];
cout<<“Enter data : “<<endl;
for(i=0 ; i<12 ; i ++)
{
cin>>a{i];
}
satistic.s();
s.avg(int * a );
getch();
}

इस code मे , दो class calculator और satistic को define किया गया है | जिसमे
class calculator मे , variable a और b को define किया गया है | और इसके अलावा चार function को define किया गया है | इस function मे variable name a और b को use किया जाता है |
class satistic मे , एक और variable a को उसी किया गया जो की class calculator मे define किया गया है | अतः class scope का सबसे बड़ा advantage निन्म होता है  |  की एक name जिसे किसी class मे define किया गया है उसे किसी और class मे define किया जाता है |

इस article मे , class scope को discuss किया गया है इसके बाद के article मे , abstract data type को discuss करेगे |

Sbistudy

Recent Posts

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

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

22 hours 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