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

STATIC EXAMPLE in c++ language , STATIC program source code with explanation in hindi

STATIC program source code with explanation in hindi , STATIC EXAMPLE in c++ language :-
इससे पहले के article मे , c++ language के  कुछ advance उदाहरणों को discuss किया है जो की static data type और static variable और static object के उदाहरन को discuss करेगे |
उदाहरन – 1
इस उदाहरन class को static function और static class  को use किया गया है  |
Explanation
सबसे पहले  static class Example को define किया जाता है |
इसमें  static variable a को define किया  जाता है | इसके बाद function () को declare किया जाता है |
function() मे
class मे define static variable को call किया जाता है |
इसके बाद static variable की value को display किया जाता है |
इसके बाद main() function को डेफिन किया जाता है | जिसमे एक template class example मे से variable a को define किया जाता है  |
उसके बाद  class example के लिए object को define किया जाता है |
इसके बाद object से class function को call किया जाता है | जिसमे ‘8’ को pass किया जाता है |
#include<stdio.h>
#include<conio.h>
class Example {
public :
static int a;
static int function(int c) {
cout << “call of Static member function “;
cout << “\nThe value of c is: ” << c ;
}
};
int Example::a=28;
void main() {
Example obj;
Example::func(8);
cout << “\nThe value of the static data member a is: ” << obj.a;
getch();
}
इसका आउटपुट होगा :
call of Static member function
The value of c  : 28
The value of the static data member a is: 8
उदाहरन -2
इस उदहारण मे , static object को declare किया जाता है |
Explantion
सबसे पहले  class pool को define किया जाता है |
इसमें  normal variable a को define किया  जाता है | इसके बाद function () को declare किया जाता है | जबकि पहले वाले उदाहरन मे static variable को define किया जाता है | अतः इसकी value को कभी भी change किया जा सकता है |
function() मे
class मे define normal variable को call किया जाता है |
इसके बाद normal variable की value को display किया जाता है |
इसके बाद main()function को डेफिन किया जाता है | जिसमे   class pool के लिए  static object को define किया जाता है |
इसके बाद object से class function को call किया जाता है | जिसमे कोई भी function मे pass नहीं  किया जाता है |
source code
#include <iostream>
using namespace std;
class pool {
public :
int function () {
int c = 20;
cout << “The value of c  : ” << c ;
}
};
void main() {
static pool b;
b.function ();
getch();
}
इसका आउटपुट होगा :
The value of c  : 20
उदाहरन -3
इस function मे static variable को define किया जाता है |
Explantion
सबसे पहले  class display को define किया जाता है |
इसमें  दो static variable a और b को define किया  जाता है जिसमे मे से a की value को initail किया जाता है | और b की value को 12 से initial किया जाता है |
function() मे
class मे  दो  normal variable को define किया जाता है |
इसके बाद  दो static variables की value को display किया जाता है |
इसके बाद main()function को डेफिन किया जाता है | जिसमे   class display के लिए  object ‘d’ को define किया जाता है |
इसके बाद object ‘d’ से  function को call किया जाता है | जिसमे कोई भी function मे pass नहीं  किया जाता है | जब इस function को call किया जाता है तब function के variable ‘a’ की value मे यूजर द्वारा value को input किया जाता है | को print किया जाता है |
और इसके बाद static variable जिसे value को initial किया गया है को print किया जाता है |
source code
#include <iostream>
using namespace std;
class display  {
public :
int function () {
static int a;
static int b = 12;
cout<<“enter value : “<<endl;
cin>>a;
cout << ” Static variable a is: ” << a;
cout << “\n Static variable b is: ” << b;
}
};
void main() {
display d;
d.function ();
getch();
}
Sbistudy

Recent Posts

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

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

2 days ago

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

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

4 days ago

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

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

6 days ago

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

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

6 days ago

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

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

6 days 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