Introduction to CPP (CPP का परिचय)
C++ एक सामान्य-उद्देश्य, ऑब्जेक्ट-ओरिएंटेड भाषा है जिसे 1979 में बजरने स्ट्रॉस्ट्रुप द्वारा विकसित किया गया था। यह Clang का प्रोटोटाइप है। इसमें OOP अवधारणाएँ (classes, objects, encapsulation, inheritance, and polymorphism) शामिल हैं। आज, C++ का व्यापक रूप से वायर्ड सिस्टम (ऑपरेटिंग सिस्टम), गेमिंग (PUBG, GTA), एम्बेडेड सिस्टम (IoT जर्नल), या प्रतिस्पर्धी प्रोग्रामिंग (competitive programming) तक के अनुप्रयोगों में उपयोग किया जाता है।
Table of Contents
ToggleC++ Character Set
Character Set मतलब C++ में use होने वाले सभी valid characters का collection। यह सेट परिभाषित करता है कि किस भाषा में कौन-कौन से प्रतीकों, अक्षरों, अंकों का उपयोग किया जा सकता है।
Character Set में शामिल होते हैं
- Alphabets (अक्षर) :
- Uppercase Letters: A to Z
- Lowercase Letters: a to z
- Digits (अंक) : 0 1 2 3 4 5 6 7 8 9
- Special Symbols (विशेष प्रतीक) :
- Arithmetic Operators (अंकगणितीय ऑपरेटर) : + , – , * , / , %
- Relational (संबंधपरक) : > , < , >= , <= , == , !=
- Punctuation (विराम चिह्न) : ? ; . : #
- Brackets (कोष्ठक) : { } , [ ] , ( )
- Others (अन्य) : @ , $ , _ , & , ^
- White Spaces : space, tab, newline – इनका use पठनीयता(readability) बढ़ाने के लिए किया जाता है|
Tokens
C++ में टोकन सबसे छोटी सार्थक इकाइयाँ (meaningful units) होती हैं। कंपाइलर प्रोग्राम को टोकन में तोड़ देता है।
Types of Tokens (टोकन के प्रकार)
- शुरू letter या underscore _ से होना चाहिए
- बीच में space नहीं होना चाहिए
- case-sensitiveहोतेहैं
- Example: age, _totalMarks, calculateSum
- Integer Constant → 10, 45, -88
- Floating → 3.14, 2.0
- Character → ‘A’, ‘Z’
- String → “Hello”, “C++”
Program Structure
C++ Program generally इस structure में होता है:
#include <iostream>
using namespace std;
int main() {
cout << “Hello World”;
return 0;
}
Explanation (स्पष्टीकरण)
- #include <iostream> → इनपुट/आउटपुट के लिए हेडर फ़ाइल
- using namespace std; → Standard namespace का उपयोग
- int main() → Program execution start point
- cout → Output statement (आउटपुट)
- return 0; → Successful termination (सफल समाप्ति)
Data Types
Data Types decide करते हैं कि variable में किस प्रकार का data store होगा।
- Primary Data Types ( प्राथमिक डेटा प्रकार )
- int → Integer values (पूर्णांक मान)
- float → Decimal values (दशमलव मान)
- char → Single character ( एकल वर्ण)
- double → Large decimal ( बड़ा दशमलव)
- bool → True/False (सत्य/असत्य)
- Derived Data Types ( व्युत्पन्न डेटा प्रकार )
- Array
- Pointer
- Function
- User Defined ( उपयोगकर्ता परिभाषित )
- Structure, Union, Class, Enum