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

Exception in c++ language in hindi , ofstream , ifstream , fstream , Exception Example

ofstream , ifstream , fstream , Exception Example , Exception in c++ language in hindi :-

इससे पहले के article मे , file handling को discuss किया था | अब इस article मे exception handeling को discuss करेगे | इससे पहले एक file handeling के सार को discuss करेगे |

file handling मे किसी file से data को read और write करने के operation को perform करने के method को discuss करते है | क्सिसी file को use करने एक लिए निन्म operation को perform करता है |
open an file : इस operation मे किसी file को open किया जाता है इसके लिए निन्म syntax को use किया जाता है :-
open();
इस file को open करने के लिए किया जाता है |
close() : इस function का use किसी file को क्लोज करने के लिए किया जाता है |
इसके अलावा निन्म command को use किया जाता है |
1. ofstream
इस data type क use output file stream के लिए किया जाता है | इस data type से file को create किया जाता है और इसमें केवल data को लिखा जाता है |.

2. ifstream
इस data type क use input file stream के लिए किया जाता है | इस data type से file को create किया जाता है और इसमें केवल data को  पढ़ा  जाता है |

3. fstream
इस data type को use file stream के लिए किया जाता है | इसमें ifstream और ofstream की तरह कार्य करता है | यानि इस data type का use किसी file को create , read और write करने एक लिए किया जाता है | समतातः इस data type का use ifstream और ofstream से ज्यादा किया जाता है |

इस article मे , exception handeling को discuss करेगे | जिसका use किसी c++ language मे काफी ज्यादा होता है |
exception एक problem है जो की किसी किसी प्रोग्राम के execution की समय generate होता है | c++ execution किसी exceptional circumstance(परिस्तिथि) मे प्राप्त होता है जब कोई प्रोग्राम run होता है | जैसे किसी प्रोग्राम मे 1 को 0 से divid करना |
exceptional का use प्रोग्राम के एक पार्ट सी control को प्रोग्राम के दुसरे प[art मे shift करने के लिए किया जाता है | c++ exception handling मे तीन keyword होते है :-
try , catch और Throw | इस keyword का use निन्म task के लिय किया जाता है :-

Throw : Throw keyword का use किसी exception को high ligth करने के लिए किया जाता है | जब किसी  प्रोग्राम मे exception प्रॉब्लम आती है तब इस keyword को use किया जाता है |

catch : इस keyword से किसी प्रोग्राम मे से throw किसी गये exception को catch किया जाता है | अतः इस keyword से किसी प्रोग्राम मे से place को indentify किया जाता है झा पर exception को handel करना है | इस keyword का नाम catch इसलिए है क्योकि इस keyword का use किसी exception को catch करने के लिए किया जाता है |

try : इस keyword का use किसी प्रोग्राम के block को indetify करने के लिए किया जाता है जिसमे किसी exceptionको activate किया जता है | इस block मे एक या एक से ज्यादा catch statement हो सकता है |

उदाहरन के लिए किसी code block मे exception को generate किया जाता है | किसी method मे , किसीexception को catch करने के लिए try – catch statement को use किया जाता है | try/catch block को किसी प्रोग्राम block मे बीच मे execute किया जाता है | जिससे exception बन जाता है | किसी  try/catch block  मे declare किये गए block का mode protected होता है |the syntax for using try/catch निन्म है  −

try {
// protected code
} catch( ExceptionName E1 ) {
// catch block
} catch( ExceptionName E2 ) {
// catch block
} catch( ExceptionName EN ) {
// catch block
}

Exception Example
जैसे की exception का उदाहरन निन्म है :
#include<iostream>
#include<conio>
using namespace std;
void main()
{
int a , b ;
a=0;
b=1;
int c = b/a ; // exception example
cout<<“Exception value : “<<c;
getch();
}
इस उदाहरन मे , जब 1 को 0 से divid किया जाता है तब infinite value मिलती है जो की c++ language मे exception को generate होता है |

exception handling का निन्म application होता है :
1. Error Handling code को  Normal Code से Separation :
नोरमल programing code मे , error को handel करने के लिए if else statement को use करता है | इस method मे , error कपड़े नोरमल code मे मिक्स हो जाता है |और इस तरह का code less readable and maintainable होता है |try catch blocks से error code को नार्मल फ्लो से अलग किया जाता है |

2) Functions/Methods can handle any exceptions they choose:
किसी function मे एक या एक से ज्यादा  exceptions होता है | लेकिन इसमें से कुछ ही को error handling मे use किया जाता है | जब किसी कॉलर किसी exceptionsको catch नहीं करता है जब exceptions को caller by caller catch किया जाता है |
c++ language , function को किसी exceptions को specify करने के लिए किया जाता है जिसे throw keywordसे प्रोगार्म से throw किया जाता है |

3) Grouping of Error Types:
c++ language , class का data type और object को किसी exceptions की तरह throw किया जाता है | इस तरह  a hierarchy of exception objects, group exceptions in namespaces or classes को बना सकता है और  इसके type की हिसाब इसे category भी कर सकते है |

इस article मे exception के basic को discuss किया है अब आगे के article मे advance concept को discuss करेगे |

Sbistudy

Recent Posts

द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन क्या हैं differential equations of second order and special functions in hindi

अध्याय - द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन (Differential Equations of Second Order…

3 hours ago

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

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

3 days ago

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

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

5 days ago

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

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

1 week ago

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

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

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