तो स्वागत है आपका। 👋
अगर आपने C Programming सीखी है और अब एक step आगे जाना चाहते हैं, तो C++ आपके लिए काफी useful language हो सकती है।
C++ में C के कई basic concepts मिलते हैं, लेकिन इसके साथ आपको OOP, STL, Templates, Classes, Objects, Inheritance, Polymorphism और बहुत कुछ मिलता है।
शुरुआत में C++ थोड़ी बड़ी लग सकती है क्योंकि इसमें सीखने के लिए काफी सारे concepts हैं। लेकिन अगर हम इसे छोटे-छोटे parts में समझें, तो चीजें काफी आसान हो जाती हैं।
इस Complete Cheat Sheet में हम C++ के important topics को एक ही जगह समझेंगे।
आपको यहाँ मिलेंगे:
C++ Basic Syntax
Variables और Data Types
Operators
Conditions
Loops
Functions
Arrays
Strings
Pointers
References
Classes & Objects
OOP
Inheritance
Polymorphism
Encapsulation
Abstraction
Constructors & Destructors
Templates
STL
Vector
List
Set
Map
Stack
Queue
Algorithms
Iterators
Lambda
Smart Pointers
Exception Handling
File Handling
Modern C++ Basics
💻 C++ क्या है?
C++ एक general-purpose programming language है।
यह C language से develop हुई और इसमें object-oriented programming के साथ कई powerful features मिलते हैं।
C++ का इस्तेमाल अलग-अलग तरह के software और applications में होता है, जैसे:
Game Development
Desktop Software
System Software
Embedded Systems
High-performance Applications
Competitive Programming
Graphics और Simulation
🚀 पहला C++ Program
सबसे basic C++ program:
#include <iostream>
int main()
{
std::cout << "Hello World";
return 0;
}
Output:
Hello World
यहाँ:
#include <iostream>
Input और output से जुड़े tools के लिए header include करता है।
int main()
Program का main function है।
std::cout
Screen पर output दिखाने के लिए use होता है।
📦 using namespace std
Beginners को अक्सर ऐसा code दिखाई देता है:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World";
return 0;
}
using namespace std; की वजह से हमें हर बार std:: लिखने की जरूरत नहीं पड़ती।
छोटे beginner programs में यह common है। बड़े projects में नामों को साफ रखने के लिए std:: का direct use भी किया जाता है।
📝 C++ Comments
Single-line comment:
// This is a comment
Multi-line comment:
/*
This is
a multi-line comment
*/
Comments compiler के लिए program का हिस्सा नहीं होते।
🔢 C++ Variables
Variable में data store किया जाता है।
int age = 25;
double price = 99.50;
char grade = 'A';
bool passed = true;
String:
std::string name = "Rahul";
इसके लिए:
#include <string>
use किया जा सकता है।
📊 C++ Data Types
Common data types:
| Type | Example |
|---|---|
int | 10 |
float | 10.5f |
double | 10.55 |
char | 'A' |
bool | true |
void | No value |
std::string | "Hello" |
Integer types में short, long और long long भी use किए जा सकते हैं।
🔢 Constants
जिस value को बाद में बदलना नहीं है, उसके लिए const useful है।
const double PI = 3.14159;
अब:
PI = 4.0;
करना valid नहीं होगा।
➕ C++ Operators
Arithmetic Operators
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder
Example:
int a = 10;
int b = 3;
std::cout << a + b;
std::cout << a % b;
🔍 Comparison Operators
== Equal
!= Not Equal
> Greater
< Smaller
>= Greater or Equal
<= Smaller or Equal
Example:
if (age >= 18)
{
std::cout << "Adult";
}
🧠 Logical Operators
&& AND
|| OR
! NOT
Example:
if (age >= 18 && age <= 60)
{
std::cout << "Valid";
}
⚡ Assignment Operators
=
+=
-=
*=
/=
%=
Example:
int x = 10;
x += 5;
अब x की value 15 होगी।
🔄 Increment और Decrement
x++;
x--;
और:
++x;
--x;
Prefix और postfix expressions में value use होने का तरीका अलग हो सकता है।
🔀 if-else
int marks = 75;
if (marks >= 40)
{
std::cout << "Pass";
}
else
{
std::cout << "Fail";
}
🎯 else-if
if (marks >= 80)
{
std::cout << "A Grade";
}
else if (marks >= 60)
{
std::cout << "B Grade";
}
else
{
std::cout << "C Grade";
}
🔢 switch
Fixed options के लिए switch useful है।
int choice = 2;
switch (choice)
{
case 1:
std::cout << "Start";
break;
case 2:
std::cout << "Settings";
break;
default:
std::cout << "Invalid";
}
🔁 for Loop
for (int i = 1; i <= 5; i++)
{
std::cout << i << '\n';
}
🔄 while Loop
int i = 1;
while (i <= 5)
{
std::cout << i << '\n';
i++;
}
🔃 do-while Loop
int i = 1;
do
{
std::cout << i << '\n';
i++;
} while (i <= 5);
इसमें loop body कम से कम एक बार run होती है।
🛑 break
Loop को वहीं रोकने के लिए:
for (int i = 1; i <= 10; i++)
{
if (i == 5)
break;
std::cout << i << '\n';
}
⏭️ continue
Current iteration skip करने के लिए:
for (int i = 1; i <= 5; i++)
{
if (i == 3)
continue;
std::cout << i << '\n';
}
📦 C++ Arrays
एक ही type की कई values store करने के लिए array use कर सकते हैं।
int numbers[5] = {10, 20, 30, 40, 50};
Access:
std::cout << numbers[0];
Index 0 से शुरू होता है।
🔢 Multidimensional Array
int matrix[2][3] =
{
{1, 2, 3},
{4, 5, 6}
};
Access:
std::cout << matrix[1][2];
Output:
6
🔤 C++ String
C++ में text के लिए std::string बहुत useful है।
#include <string>
std::string name = "CodeSardar";
कुछ useful methods:
name.length();
name.size();
name.empty();
name.substr(0, 4);
name.find("Sardar");
name.append(" Channel");
name.push_back('!');
name.pop_back();
🔄 String Compare
std::string a = "Hello";
std::string b = "Hello";
if (a == b)
{
std::cout << "Same";
}
🛠️ C++ Functions
Function reusable code block है।
void hello()
{
std::cout << "Hello";
}
Call:
hello();
📥 Function Parameters
int add(int a, int b)
{
return a + b;
}
Call:
int result = add(10, 20);
📤 Return Value
int square(int n)
{
return n * n;
}
Use:
std::cout << square(5);
Output:
25
🔄 Function Overloading
एक ही नाम के functions अलग-अलग parameters के साथ बनाए जा सकते हैं।
int add(int a, int b)
{
return a + b;
}
double add(double a, double b)
{
return a + b;
}
इसे Function Overloading कहते हैं।
🧠 Default Arguments
Function parameter की default value दी जा सकती है।
void greet(std::string name = "Guest")
{
std::cout << "Hello " << name;
}
अब:
greet();
से "Guest" use होगा।
👉 C++ References
Reference किसी existing variable का दूसरा नाम जैसा होता है।
int number = 10;
int& ref = number;
अब:
ref = 50;
करने पर number की value भी 50 हो जाएगी।
👉 C++ Pointers
Pointer में memory address store किया जा सकता है।
int number = 10;
int* ptr = &number;
Value:
std::cout << *ptr;
Address:
std::cout << ptr;
⭐ Pointer और Reference में Difference
| Pointer | Reference |
|---|---|
| Address store करता है | Existing variable का alias |
nullptr हो सकता है | सामान्य reference को valid object से bind किया जाता है |
* से dereference | सामान्य use में सीधे variable जैसा |
| Pointer को reassign किया जा सकता है | Reference binding बदलना सामान्य तरीके से नहीं होता |
🏗️ C++ Class
Class को object का blueprint समझ सकते हैं।
class Student
{
public:
std::string name;
int age;
};
Object:
Student s1;
s1.name = "Rahul";
s1.age = 20;
🧱 Constructor
Object बनते समय constructor call होता है।
class Student
{
public:
Student()
{
std::cout << "Object Created";
}
};
🧩 Parameterized Constructor
class Student
{
public:
std::string name;
Student(std::string n)
{
name = n;
}
};
Object:
Student s("Rahul");
🗑️ Destructor
Object destroy होने पर destructor call हो सकता है।
class Test
{
public:
~Test()
{
std::cout << "Object Destroyed";
}
};
🔒 Encapsulation
Data और functions को class में रखना और access को control करना encapsulation का basic idea है।
class Account
{
private:
double balance = 0;
public:
void setBalance(double value)
{
balance = value;
}
double getBalance()
{
return balance;
}
};
👨👦 Inheritance
एक class दूसरी class से features ले सकती है।
class Animal
{
public:
void eat()
{
std::cout << "Eating";
}
};
class Dog : public Animal
{
public:
void bark()
{
std::cout << "Barking";
}
};
अब:
Dog d;
d.eat();
d.bark();
🔄 Polymorphism
एक ही interface अलग-अलग classes में अलग behavior दे सकता है।
Runtime polymorphism का common example:
class Animal
{
public:
virtual void sound()
{
std::cout << "Animal Sound";
}
virtual ~Animal() = default;
};
class Dog : public Animal
{
public:
void sound() override
{
std::cout << "Bark";
}
};
Use:
Animal* animal = new Dog();
animal->sound();
delete animal;
Output:
Bark
Modern C++ में override लिखना अच्छी practice है।
🎭 Abstraction
जरूरी interface दिखाना और अंदर की implementation details को hide करना abstraction का basic idea है।
Example:
class Shape
{
public:
virtual void draw() = 0;
virtual ~Shape() = default;
};
यह एक abstract class बन जाती है।
🔐 Access Specifiers
C++ में common access specifiers:
public
private
protected
| Modifier | Basic Meaning |
|---|---|
public | बाहर से access किया जा सकता है |
private | class के अंदर |
protected | class और derived classes के लिए |
🧬 Multiple Inheritance
C++ में एक class एक से ज्यादा classes से inherit कर सकती है।
class A
{
};
class B
{
};
class C : public A, public B
{
};
🧩 Virtual Function
Runtime polymorphism के लिए base class में function को virtual बनाया जा सकता है।
class Animal
{
public:
virtual void sound()
{
std::cout << "Sound";
}
virtual ~Animal() = default;
};
📦 C++ STL क्या है?
STL का मतलब है:
Standard Template Library
STL में ready-made containers, algorithms, iterators और utilities मिलते हैं।
अगर आपको data store, search, sort या process करना है, तो STL बहुत काम आती है।
STL के important parts:
Containers
Algorithms
Iterators
Function Objects
Utilities
🧺 vector
C++ STL का सबसे popular container है:
std::vector<int> numbers;
Values add करें:
numbers.push_back(10);
numbers.push_back(20);
numbers.push_back(30);
Access:
std::cout << numbers[0];
Size:
numbers.size();
Last element:
numbers.back();
First element:
numbers.front();
Last remove:
numbers.pop_back();
📋 vector Important Methods
push_back()
pop_back()
size()
empty()
clear()
front()
back()
at()
begin()
end()
insert()
erase()
resize()
reserve()
capacity()
Example:
numbers.erase(numbers.begin());
🔗 list
std::list doubly linked list container है।
std::list<int> numbers;
numbers.push_back(10);
numbers.push_front(5);
Useful:
push_back()
push_front()
pop_back()
pop_front()
insert()
erase()
sort()
reverse()
remove()
size()
↔️ deque
deque यानी double-ended queue।
इसमें दोनों sides से data add/remove किया जा सकता है।
std::deque<int> d;
d.push_back(10);
d.push_front(5);
🚫 set
std::set में unique sorted values रखी जा सकती हैं।
std::set<int> numbers;
numbers.insert(30);
numbers.insert(10);
numbers.insert(30);
numbers.insert(20);
Values unique रहेंगी और default ordering में sorted रहेंगी।
🔢 unordered_set
अगर आपको sorted order की जरूरत नहीं है और hash-based lookup चाहिए:
std::unordered_set<int> numbers;
numbers.insert(10);
numbers.insert(20);
🗺️ map
std::map key-value data रखने के लिए useful है।
std::map<int, std::string> students;
students[1] = "Rahul";
students[2] = "Aman";
Access:
std::cout << students[1];
⚡ unordered_map
Hash table based key-value container:
std::unordered_map<int, std::string> students;
students[1] = "Rahul";
students[2] = "Aman";
यह sorted order maintain नहीं करता।
📚 stack
Stack में LIFO concept होता है:
Last In, First Out
std::stack<int> s;
s.push(10);
s.push(20);
std::cout << s.top();
s.pop();
Important:
push()
pop()
top()
empty()
size()
🚶 queue
Queue में FIFO concept होता है:
First In, First Out
std::queue<int> q;
q.push(10);
q.push(20);
std::cout << q.front();
q.pop();
↔️ priority_queue
Priority के हिसाब से element access करने के लिए:
std::priority_queue<int> pq;
pq.push(10);
pq.push(50);
pq.push(20);
std::cout << pq.top();
Default priority_queue में सबसे बड़ा element top पर होता है।
🔁 Iterators
Iterator container के elements पर चलने के लिए use होता है।
Example:
std::vector<int> numbers = {10, 20, 30};
for (auto it = numbers.begin(); it != numbers.end(); ++it)
{
std::cout << *it << '\n';
}
Common functions:
begin()
end()
cbegin()
cend()
rbegin()
rend()
🔍 STL Algorithms
C++ STL में बहुत सारे ready-made algorithms हैं।
Common algorithms:
sort()
reverse()
find()
count()
min_element()
max_element()
binary_search()
lower_bound()
upper_bound()
swap()
fill()
accumulate()
🔢 sort()
std::vector<int> numbers = {5, 2, 8, 1};
std::sort(numbers.begin(), numbers.end());
अब numbers sorted order में होंगे।
🔄 reverse()
std::reverse(numbers.begin(), numbers.end());
🔍 find()
auto it = std::find(
numbers.begin(),
numbers.end(),
8
);
अगर value मिलती है तो iterator उस element पर होता है, वरना end() मिलता है।
🔢 count()
किसी value की frequency:
int total = std::count(
numbers.begin(),
numbers.end(),
5
);
🎯 min_element() और max_element()
auto min = std::min_element(
numbers.begin(),
numbers.end()
);
auto max = std::max_element(
numbers.begin(),
numbers.end()
);
🔎 binary_search()
Sorted range में value search करने के लिए:
bool found = std::binary_search(
numbers.begin(),
numbers.end(),
8
);
📍 lower_bound()
Sorted range में पहली ऐसी position देता है जहाँ value insert की जा सकती है बिना ordering तोड़े।
auto it = std::lower_bound(
numbers.begin(),
numbers.end(),
5
);
📍 upper_bound()
Value से बड़ी पहली position:
auto it = std::upper_bound(
numbers.begin(),
numbers.end(),
5
);
➕ accumulate()
Numbers का total निकालने के लिए:
int total = std::accumulate(
numbers.begin(),
numbers.end(),
0
);
इसके लिए:
#include <numeric>
use किया जाता है।
🧩 Templates क्या हैं?
Templates C++ का बहुत important feature है।
इनकी मदद से ऐसा generic code लिखा जा सकता है जो अलग-अलग data types के साथ काम कर सके।
Example:
template <typename T>
T add(T a, T b)
{
return a + b;
}
Use:
std::cout << add(10, 20);
और:
std::cout << add(2.5, 3.5);
📦 Class Template
template <typename T>
class Box
{
private:
T value;
public:
Box(T v)
{
value = v;
}
T getValue()
{
return value;
}
};
Use:
Box<int> a(100);
Box<std::string> b("Hello");
🧠 auto Keyword
Compiler को type खुद समझने देना हो तो auto use कर सकते हैं।
auto age = 25;
auto price = 99.99;
Iterator के साथ यह बहुत useful है:
auto it = numbers.begin();
🪄 Lambda Expression
Lambda एक छोटा anonymous function जैसा है।
auto add = [](int a, int b)
{
return a + b;
};
Call:
std::cout << add(10, 20);
📌 Range-Based for Loop
Container के elements पढ़ने का आसान तरीका:
for (const auto& number : numbers)
{
std::cout << number << '\n';
}
यह STL containers के साथ बहुत useful है।
🧠 Smart Pointers
Modern C++ में memory management के लिए smart pointers बहुत useful हैं।
Common types:
unique_ptr
shared_ptr
weak_ptr
unique_ptr
auto ptr = std::make_unique<int>(100);
shared_ptr
auto ptr = std::make_shared<int>(100);
weak_ptr
shared_ptr के object को बिना ownership बढ़ाए observe करने के लिए useful हो सकता है।
Smart pointers के लिए:
#include <memory>
use करें।
⚠️ Exception Handling
C++ में exceptions handle करने के लिए:
try
catch
throw
use किए जाते हैं।
Example:
try
{
throw std::runtime_error("Something went wrong");
}
catch (const std::exception& e)
{
std::cout << e.what();
}
📁 File Handling
File open करने के लिए:
std::ofstream file("data.txt");
Write:
file << "Hello C++";
Read:
std::ifstream file("data.txt");
std::string text;
std::getline(file, text);
Common classes:
ifstream
ofstream
fstream
🧮 Useful C++ Math Functions
<cmath> में कई useful functions मिलते हैं।
sqrt()
pow()
abs()
fabs()
ceil()
floor()
round()
sin()
cos()
tan()
log()
log10()
exp()
Example:
double result = std::sqrt(25.0);
🔤 Character Functions
<cctype> में useful functions:
isalpha()
isdigit()
isalnum()
islower()
isupper()
isspace()
tolower()
toupper()
Example:
char ch = 'a';
if (std::isalpha(
static_cast<unsigned char>(ch)))
{
std::cout << "Letter";
}
🧵 Threads का Basic Idea
C++ में multiple tasks को handle करने के लिए threading support मिलता है।
Basic example:
#include <thread>
void task()
{
std::cout << "Task Running";
}
int main()
{
std::thread t(task);
t.join();
return 0;
}
Real applications में thread synchronization और shared data का भी ध्यान रखना पड़ता है।
🧪 C++ Debugging
अगर program compile हो रहा है लेकिन सही result नहीं दे रहा, तो debugger काफी useful है।
आप:
Breakpoint लगा सकते हैं
Variables की value देख सकते हैं
Program step-by-step चला सकते हैं
Call stack check कर सकते हैं
Runtime behavior समझ सकते हैं
Debugging सीखना programming का important हिस्सा है।
🛠️ C++ Compilation
GCC या G++ compiler से C++ file compile कर सकते हैं।
अगर file है:
main.cpp
तो:
g++ main.cpp -o main
Linux/macOS पर run:
./main
Windows पर:
main.exe
📦 C++ Standard Library के Important Headers
| Header | Main Use |
|---|---|
<iostream> | Input / Output |
<string> | String |
<vector> | Vector |
<array> | Fixed-size array |
<list> | Linked list |
<deque> | Double-ended queue |
<set> | Set |
<map> | Map |
<unordered_set> | Hash set |
<unordered_map> | Hash map |
<stack> | Stack |
<queue> | Queue |
<algorithm> | Algorithms |
<iterator> | Iterators |
<numeric> | Numeric algorithms |
<memory> | Smart pointers |
<fstream> | File handling |
<sstream> | String streams |
<cmath> | Math |
<cctype> | Character functions |
<chrono> | Time utilities |
<thread> | Threads |
<random> | Random number generation |
📊 STL Containers Quick Table
| Container | Simple Use |
|---|---|
vector | Dynamic array |
array | Fixed-size array |
list | Doubly linked list |
deque | Both ends से operations |
set | Unique sorted values |
unordered_set | Hash-based unique values |
map | Sorted key-value data |
unordered_map | Hash-based key-value data |
stack | LIFO |
queue | FIFO |
priority_queue | Priority-based access |
⚡ C++ STL Quick Cheat Sheet
// Vector
std::vector<int> v;
v.push_back(10);
v.pop_back();
v.size();
v.empty();
// Set
std::set<int> s;
s.insert(10);
s.erase(10);
s.find(10);
// Map
std::map<int, std::string> m;
m[1] = "Rahul";
m.erase(1);
// Stack
std::stack<int> st;
st.push(10);
st.top();
st.pop();
// Queue
std::queue<int> q;
q.push(10);
q.front();
q.pop();
// Algorithms
std::sort(v.begin(), v.end());
std::reverse(v.begin(), v.end());
std::find(v.begin(), v.end(), 10);
⚠️ Beginners की Common C++ Mistakes
1. = और == को confuse करना
x = 10;
Assignment है।
x == 10;
Comparison है।
2. Array के बाहर access करना
int numbers[5];
numbers[5] = 10;
यह गलत है क्योंकि valid indexes 0 से 4 तक हैं।
3. Uninitialized pointer use करना
ऐसा pointer:
int* ptr;
बिना सही initialization के dereference नहीं करना चाहिए।
बेहतर:
int* ptr = nullptr;
4. Memory manually manage करते समय mistake
अगर आप manually new use करते हैं:
int* p = new int(10);
तो matching:
delete p;
करना जरूरी होता है।
जहाँ possible हो, modern C++ में smart pointers prefer करना आसान और safer approach हो सकता है।
5. vector में index की गलती
std::vector<int> v = {10, 20};
std::cout << v[5];
यह valid element नहीं है।
🎯 C++ सीखने का सही Order
अगर आप beginner हैं, तो इस order में सीखना काफी आसान रहेगा:
C++ Basics
↓
Variables & Data Types
↓
Operators
↓
if / else
↓
Loops
↓
Functions
↓
Arrays
↓
Strings
↓
Pointers & References
↓
Classes & Objects
↓
OOP
↓
STL
↓
Templates
↓
Algorithms
↓
Lambda
↓
Smart Pointers
↓
File Handling
↓
Exception Handling
↓
Threads
↓
Projects
🧪 Beginner C++ Projects
सीखने के बाद इन projects पर practice कर सकते हैं:
Basic Projects
Calculator
Number Guessing Game
Simple Quiz
Unit Converter
Age Calculator
Intermediate Projects
Student Management System
Contact Book
Bank Account System
To-Do List
Library Management
STL Practice
Vector Based Program
Sorting Program
Search Program
Frequency Counter
Leaderboard
Simple Inventory System
💡 Pro Tip
C++ में बहुत सारे keywords और functions देखकर उन्हें एक साथ याद करने की कोशिश मत कीजिए।
पहले एक concept सीखिए और उसी पर छोटा program बनाइए।
जैसे:
Vector सीखा?
एक छोटा program बनाकर numbers add, remove और sort करके देखिए।
Class सीखी?
Student class बनाइए।
Inheritance सीखा?
Animal और Dog का example बनाइए।
STL Algorithm सीखा?sort(), find() और count() खुद use करके देखिए।
इस तरह सीखने से syntax के साथ उसका actual use भी समझ आएगा।
⚠️ Note
C++ में अलग-अलग standards जैसे C++11, C++14, C++17, C++20 और C++23 के साथ language और standard library में नए features आते रहे हैं।
इसलिए किसी पुराने tutorial में दिया गया code आपके compiler या current project में थोड़ा अलग हो सकता है।
अगर आप नया project शुरू कर रहे हैं, तो अपने compiler और project के supported C++ standard को जरूर check करें।
❓ C++ FAQs
C++ क्या है?
C++ एक general-purpose programming language है जिसमें procedural programming के साथ object-oriented और generic programming जैसे features मिलते हैं।
क्या C++ beginners के लिए सही है?
हाँ। C++ में शुरुआत में concepts ज्यादा लग सकते हैं, लेकिन step-by-step सीखने पर इसे समझा जा सकता है।
C और C++ में क्या difference है?
C मुख्य रूप से procedural programming language है, जबकि C++ में OOP, templates, STL और कई दूसरे features भी मिलते हैं।
STL क्या है?
STL यानी Standard Template Library। इसमें containers, algorithms और iterators जैसे ready-made tools मिलते हैं।
Vector क्या है?
vector एक dynamic array जैसा container है, जिसका size जरूरत के हिसाब से बढ़ सकता है।
Map क्या है?
map key और value के रूप में data store करने वाला associative container है।
Set क्या है?
set unique values store करता है और सामान्य set में values sorted order में रहती हैं।
Template क्या है?
Template की मदद से generic code लिखा जा सकता है जो अलग-अलग data types के साथ काम कर सके।
Pointer क्या है?
Pointer ऐसा variable है जिसमें किसी object या variable का memory address store किया जा सकता है।
Reference क्या है?
Reference किसी existing object या variable का दूसरा नाम जैसा होता है।
C++ में OOP क्या है?
OOP यानी Object-Oriented Programming। इसमें class, object, inheritance, polymorphism, encapsulation और abstraction जैसे concepts आते हैं।
C++ में smart pointer क्या है?
Smart pointer ऐसा object है जो dynamically allocated object की ownership और lifetime manage करने में मदद करता है।
C++ program कैसे compile करें?
G++ से:
g++ main.cpp -o main
फिर generated executable को run किया जा सकता है।
C++ सीखने के बाद क्या बना सकते हैं?
आप games, desktop applications, system-level programs, simulations, competitive programming solutions और कई दूसरे projects बना सकते हैं।
📘 C++ Quick Revision
C++ COMPLETE CHEAT SHEET
✓ Basics
✓ Variables & Operators
✓ Functions
✓ Arrays & Strings
✓ Pointers & References
✓ OOP
✓ Classes & Objects
✓ Inheritance
✓ Polymorphism
✓ Encapsulation
✓ Abstraction
✓ Templates
✓ STL
✓ Containers
✓ Iterators
✓ Algorithms
✓ Lambda
✓ Smart Pointers
✓ Exceptions
✓ File Handling
✓ Threads
✓ Modern C++
🚀 Final Words
C++ में बहुत सारे features हैं, इसलिए शुरुआत में यह language बड़ी लग सकती है।
लेकिन आपको सब कुछ एक साथ सीखने की जरूरत नहीं है।
पहले basic syntax, variables, conditions, loops और functions समझिए।
फिर arrays, strings, pointers और references पर जाइए।
उसके बाद classes और OOP सीखिए और फिर STL पर focus करें।
जब vector, map, set, stack, queue, sort(), find() और दूसरे common STL tools समझ आने लगें, तो C++ में programming काफी आसान लगने लगेगी।
फिर धीरे-धीरे templates, lambda, smart pointers, exceptions और modern C++ सीख सकते हैं।
और सबसे जरूरी बात—
Code पढ़ने से ज्यादा जरूरी है code लिखना।
हर concept के बाद छोटा program बनाइए, उसे compile कीजिए, run कीजिए और error आने पर खुद उसे fix करने की कोशिश कीजिए।
यही practice आपको C++ में strong बनाएगी।
LEARN → CODE → COMPILE → DEBUG → BUILD 💻🚀
🎬 Need help? Click the button below to watch the complete step-by-step video guide tutorial!
📺 Watch Full Video Guide