Introduction of C++
- C++ Programming Language ये OOP(Object-Oriented Programming) Language है, इससे पहले भी 'Simula' ये भी OOP Language बनाई गयी थी |
- C++ में OOps concept के साथ कई features है |
- Inheritance
- Polymorphism
- Abstraction
- Encapsulation
- C++ Programming Language ये Middle Level Language है |
- C++ Programming को Windows, Linux, Mac OS या आदि Operating Systems पर चलाया जाता है |
History of C++
- C++ Programming Language को बनाने की शुरुआत 1979 में हुई |
- C Programming में ही कुछ बदल करके 'C with Classes' ये C का concept आया |
- 'C with Classes' के साथ और भी कई concepts को बनाकर Bjarne Stroustrup ने 1983 में AT & T's Bell Labs में C++ Programming का अविष्कार किया गया |
Uses of C++
- C++ Programming Language का इस्तेमाल Computer Software's बनाने के लिए किया जाता है |
- Computer Software's के साथ-साथ Drivers, Computer Hardware's, servers के लिए भी इस्तेमाल किया जाता है |
OOP ये Method Classes और Objects पर निर्धारित होता है |
OOP ये एक ऐसी concept है, जिसमे Object के data और function का data structure होता है |
C++ ये एक Procedural(C Programming जैसी) और OOP Language भी है |
नीचे OOP के कुछ concepts short में दिए हुए है |
- Class : Class का जो object उससे related उसका behavior , properties या attributes को define किया जाता है |for eg. अगर कोई Animal है | तो class में उसका behavior, उसके body के parts और उनकी संख्या इनको define किया जा सकता है |
- Object : Object को class पर create किया जाता है | Object के कई नाम हो सकते है, जो उसके data members से related होते है |
- Inheritance : Inheritance में एक मुख्य class की attributes वो अपने sub-classes को inherit करता है | Inheritance में मुख्य class को base class या parent class कहते है और उसके अन्दर या उसके subclasses को derived class या child class कहते है |
- Polymorphism : Polymorphism मतलब एक ही form में अनेक form होते है | इसमे same नाम के member function को अलग -अलग parameters होते है |example में एक shape के द्वारा square, Circle, Triangle इन सभी shapes को draw किया जा सकता है |
- Abstraction : Abstraction में कुछ जरुरत के हिसाब से important data को दिखाया जाता है और कुछ data या internal processes को hide किया जाता है |
- Encapsulation : Encapsulation data और class को combine करके एक class के अन्दर रखा जाता है | ये 'Data Abstraction' भी कहलाया जाता है |
| C++ Keywords | Description |
|---|---|
| asm | Assembly Language लिखने के लिए इस्तेमाल किया जाता है | |
| auto | Storage class का एक प्रकार है | जो Local variable के लिए भी इस्तेमाल होता है | |
| bool | boolean variable declare करने के लिए इस्तेमाल होता है | for eg. True और False |
| break | Loops या statements को break करने के लिए इस्तेमाल होता है | |
| case | Switch case statement को इस्तेमाल करने के लिए होता है | |
| catch | throw से exceptions handle करने के लिए इस्तेमाल होता है | |
| char | character variable declare करने के लिए इस्तेमाल होता है | |
| class | classes को declare करने के लिए इस्तेमाल होता है | |
| const | Const ये एक स्थिर variable के लिए इस्तेमाल होता है | |
| const_cast | Constant variable को cast किया जाता है | |
| continue | Loop को iterate किया जाता है | |
| default | Switch case statement के लिए इस्तेमाल होता है | |
| delete | Dynamic memory allocation के लिए इस्तेमाल होता है | |
| do | एक loop का प्रकार है | जिसके साथ while loop को इस्तेमाल किया जाता है | |
| double | floating-point data-type है | |
| dynamic_cast | pointer के साथ इस्तेमाल होता है | |
| else | if के साथ statement को इस्तेमाल किया जाता है | |
| enum | Enumeration data type का 'Keyword' है | |
| explicit | Constructor convert करने के लिए इस्तेमाल होता है | |
| export | template की definition को export किया जाता है | |
| extern | Storage class का एक प्रकार है | जिसका scope global होता है | |
| false | Boolean की एक value है | |
| float | Floating-point variable को declare करने के लिए इस्तेमाल होता है | |
| for | Loop का एक प्रकार है | |
| friend | non-member function; private data में access करने के लिए इस्तेमाल होता है | |
| goto | एक statement है , जिसमे label होता है | |
| if | एक statement है | जिससे condition सही है या गलत इसका पता चलता है | |
| inline | function के लिए इस्तेमाल होता है | |
| int | integer variable को declare करने के इस्तेमाल होता है | |
| long | long integer variable को declare करने के इस्तेमाल होता है | |
| mutable | एक storage class का प्रकार है | |
| namespace | same indetifiers(variables, functions, classes) अलग-अलग बताने के लिए इस्तेमाल होता है | |
| new | Dynamic memory allocation के लिए इस्तेमाल होता है | |
| operator | Overloaded operators को declare करने के लिए इस्तेमाल होता है | |
| private | Class के private members को declare करने के लिए इस्तेमाल होता है | |
| protected | Class के protected members को declare करने के लिए इस्तेमाल होता है | |
| public | Class के public members को declare करने के लिए इस्तेमाल होता है | |
| register | एक storage class का प्रकार है | |
| reinterpret_cast | Variable का cast-type change करने के लिए इस्तेमाल होता है | |
| return | function के लिए इस्तेमाल होता है | |
| short | short integer variable को declare करने के इस्तेमाल होता है | |
| signed | एक variable modifier है | |
| sizeof | variable का size return करने के लिए इस्तेमाल होता है | |
| static | एक storage class का प्रकार है | |
| static_cast | एक type_conversion है | |
| struct | structure को define या declare करने के लिए इस्तेमाल होता है | |
| switch | एक statement है | |
| template | Generic Program को लिखने के लिए इस्तेमाल होता है | |
| this | pointer को current object पर लाता है | |
| throw | Exception Handling के लिए इस्तेमाल होता है | |
| true | Boolean की एक value है | |
| try | Exception Handling के लिए इस्तेमाल होता है | |
| typedef | data type को alias_name देने के लिए इस्तेमाल होता है | |
| typeid | Object का वर्णन किया जाता है | |
| typename | Class का alternative है | |
| union | ये keyword अपने members को एक ही memory location पर assign किया जाता है | |
| unsigned | unsigned integer variable को declare करने के लिए इस्तेमाल किया जाता है | |
| using | namespace के साथ इस्तेमाल किया जाता है | |
| virtual | Runtime polymorphism के लिए इस्तेमाल होता है | |
| void | ये कुछ भी return नहीं करता | |
Program का Structure :
| Preprocessor | #include <iostream.h> |
|---|---|
| Standard Namespace | using namespace std; |
| return_type & main function | int main() |
| Opening curly brace | { |
| ostream class object | cout<<"Hello World!"; |
| return 0; | return 0; |
| Closing curly brace | } |
ये Program C++ Programming में सबसे पहला और आसान Program है | ऊपर दिया हुआ Program सात भाग में बटा हुआ है |
- Preprocessor
- Standard Namespace
- main function
- {
- cout<<"Hello World!";
- return 0;
- }
for eg. iostream.h में cin और cout आते है |
conio.h में getch function आता है |
और भी कुछ preprocessors है , जो Library functions में दिखाएंगे |
2.using namespace std; : ये एक Standard command library है | Program में input/Output के लिए इसका इस्तेमाल होता है | अगर इसका इस्तेमाल नहीं होता, तो cout और cin को कोई scope नहीं रह जाता | Program को बिना using namespace std; से इस्तेमाल किया जाता है | पर cout<< की जगह std::cout<< को लिखना पड़ता है |
3.int main() : यहाँ पर main function का return_type integer है | main function का return_type void भी लिखा जाता है पर void कोई भी value return नहीं करता | Program की शुरुआत main() function से होती है |
4.{ : हर function के codes या statements को curly brace open होने के बाद लिखा जाता है |
5.cout<<"Hello World!"; : cout को insertion operator(<<) के साथ लिखे हुए statement को output में print किया जाता है | इस statement को दो Double Quotes (" ") के अंदर लिखा जाता है |
6.return 0; : return 0 ये Program को बंद करने की अनुमति देता है | ये '0' main function को return करता है |
7.} : यहाँ पर } इस curly brace से main function को close किया है |
C++ Hello Program using namespace
Source Code :#include <iostream.h>
using namespace std;
int main(){
cout<<"Hello World!";
return 0;
}
Output :Hello World!


0 टिप्पणियाँ
Thank your for suggeustion.