C++ का परिचय: मूल बातें और अनुप्रयोग

Introduction to CPP (CPP का परिचय)

C++ एक सामान्य-उद्देश्य, ऑब्जेक्ट-ओरिएंटेड भाषा है जिसे 1979 में Bergen Stroustrup द्वारा विकसित किया गया था। यह Clang का प्रोटोटाइप है। इसमें OOP अवधारणाएँ (classes, objects, encapsulation, inheritance, and polymorphism) शामिल हैं। आज, C++ का व्यापक रूप से ऑपरेटिंग सिस्टम, गेमिंग (PUBG, GTA), एम्बेडेड सिस्टम (IOT जर्नल), या प्रतिस्पर्धी प्रोग्रामिंग (competitive programming) तक के अनुप्रयोगों में उपयोग किया जाता है।

C++ Character Set

Character Set मतलब C++ में use होने वाले सभी valid characters का collection। यह सेट परिभाषित करता है कि किस भाषा में कौन-कौन से प्रतीकों, अक्षरों, अंकों का उपयोग किया जा सकता है।

Character Set में शामिल होते हैं

  1. Alphabets (अक्षर) :
      • Uppercase Letters : A to Z
      • Lowercase Letters : a to z
  2. Digits (अंक) : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  3. Special Symbols (विशेष प्रतीक) :
      • Arithmetic Operators (अंकगणितीय ऑपरेटर) : [ + ],  [ – ],  [ * ],  [ / ],  [ % ],  [ = ]
      • Relational (संबंधपरक) : [ > ],  [ < ],  [ >= ],  [ <= ],  [ == ],  [ != ]
      • Punctuation (विराम चिह्न) : [ ? ], [ ; ], [ . ], [ : ], [ # ]
      • Brackets (कोष्ठक) : [ { } ], [ [ ] ], [ ( ) ]
      • Others (अन्य) : [ @ ], [ $ ], [ _ ], [ & ], [ ^ ]
  4. White Spaces :  space, tab, newline – इनका use पठनीयता(readability) बढ़ाने के लिए किया जाता है|

Tokens

C++ में Tokens सबसे छोटी सार्थक इकाइयाँ (meaningful units) होते हैं। Compiler program को टोकन में तोड़ देता है।

Types of Tokens (टोकन के प्रकार) : 

1. Keywords
पूर्वपरिभाषित शब्दों का विशेष अर्थ होता है। उदाहरण: int, float, return, if, else, while, class, public, private
    
2. Identifiers 
Programmer द्वारा दिए गए नाम (जैसे variable name, function name)
  Rule:
  • Starting letter या underscore ( _ ) से होना चाहिए
  • बीच में space नहीं होना चाहिए
  • case-sensitive होते हैं
  • Example: age, _totalMarks, calculateSum
3. Literals  (Constants)
निश्चित मान जो बदलते नहीं हैं।
  • Integer Constant →  10, 45, -88
  • Floating →  3.14, 2.0
  • Character →  ‘A’, ‘Z’
  • String →  “Hello”, “C++”
4.Operators 
Symbols जो Operations Perform करते हैं। Example: [ + ],  [ – ],  [ * ],  [ / ],  [ % ],  [ = ]
 
5.Punctuators Separators
Program structure maintain करने वाले symbols – [ { } ],  [ ; ],  [ , ],  [ ( ) ],  [ [ ] ]

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 होगा।

  1. Primary Data Types ( प्राथमिक डेटा प्रकार )
    • int → Integer values (पूर्णांक मान)
    • float → Decimal values (दशमलव मान)
    • char → Single character ( एकल वर्ण)
    • double → Large decimal ( बड़ा दशमलव)
    • bool → True/False (सत्य/असत्य)
  1. Derived Data Types ( व्युत्पन्न डेटा प्रकार )
    • Array
    • Pointer
    • Function
  1. User Defined ( उपयोगकर्ता परिभाषित )
    • Structure, Union, Class, Enum
error: Content is protected !!