← Back to C++ Course | Chapter 1: Introduction & Basics | Lesson 1 of 15

C++ परिचय

C++ एक fast, powerful programming language है जो games, apps, और तेज़ी से चलने की ज़रूरत वाली चीज़ों के लिए इस्तेमाल होती है। यह languages की एक sports car जैसी है: बहुत speedy लेकिन आपको careful steer करना होता है।

C++ क्या है?

C++ एक powerful, general-purpose programming language है जो C के एक extension की तरह बनाई गई। इसे अक्सर एक middle-level language कहा जाता है क्योंकि यह आपको low-level code लिखने देती है जो सीधे memory और hardware से बात करता है, साथ ही classes और templates जैसे high-level abstractions भी support करती है।

उदाहरण: What is C++?

cpp
#include <iostream>

int main() {
	// C++ extends C: low-level memory/hardware access plus
	// high-level abstractions like classes and templates.
	std::cout << "C++ is a middle-level, general-purpose language" << std::endl;
	return 0;
}

C++ क्यों सीखें?

C++ सीखना worth है क्योंकि यह large codebases को maintainable रखने वाले object-oriented structure को छोड़े बिना आपको performance और memory पर fine control देती है।

cookiescursor.com के पीछे के systems जैसे performance-sensitive backends बनाने वाली companies specifically इसी speed-and-structure combination के लिए C++ चुनती हैं।

उदाहरण: Why Learn C++?

cpp
// Include std::cout and std::cin
#include <iostream>

// Program execution starts in main()
int main() {
	// Print to the console with cout
	std::cout << "C++ combines fine performance control with OOP structure" << std::endl;
	// Return 0 to signal that the program finished successfully
	return 0;
}

C++ कैसे काम करता है

एक compiled language की तरह, आपकी C++ source file इसके चलने से पहले पूरी तरह एक compiler से native machine code में translate होती है।

क्योंकि वह translation runtime पर line-by-line की बजाय पहले से होता है, resulting program एक interpreted language से तेज़ start और execute होता है।

उदाहरण: How C++ Works

cpp
// g++ program.cpp -o program   (compiles ahead of time to machine code)
// ./program                    (runs instantly -- no interpreter needed)
#include <iostream>

int main() {
	std::cout << "Compiled once, then runs as native machine code" << std::endl;
	return 0;
}

C++ के Applications

C++ वहाँ दिखता है जहाँ raw speed और hardware control मायने रखते हैं: operating system kernels, browser engines, और real-time game engines सब आमतौर पर इसमें लिखे जाते हैं।

Databases और system utilities भी C++ पर depend करते हैं ताकि वे memory और I/O precisely manage कर सकें, इस काम को एक runtime पर छोड़ने की बजाय।

उदाहरण: Applications of C++

cpp
// Include std::cout and std::cin
#include <iostream>

// Program execution starts in main()
int main() {
	// Print to the console with cout
	std::cout << "Used in OS kernels, browser engines, game engines, and databases" << std::endl;
	// Return 0 to signal that the program finished successfully
	return 0;
}

C++ के Benefits

C++ आपको pointers के जरिए memory तक direct access देती है, जो exactly वह चीज़ है जो आपको लगभग बिना किसी runtime overhead के code लिखने देती है।

Operating systems में same portability, manual memory control के साथ combined, यही वजह है कि जब हर byte और हर cycle मायने रखता है तो C++ पसंदीदा language बनी रहती है।

उदाहरण: Benefits of C++

cpp
// Include std::cout and std::cin
#include <iostream>

// Program execution starts in main()
int main() {
	// Declare value and set it to 42
	int value = 42;
	int* ptr = &value;
	// Print to the console with cout
	std::cout << "Direct memory access via pointer: " << *ptr << std::endl;
	// Return 0 to signal that the program finished successfully
	return 0;
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह सोचना कि C++ code सीधे एक script की तरह चलता है, जब इसे पहले compile करना होता है (उदाहरण के लिए g++ main.cpp -o main) और फिर produced executable run होता है।
  2. यह मान लेना कि C++ बस कुछ extras वाली C है और यह ignore करना कि यह अपनी standard library वाली एक अलग language है, जैसे std::string और std::vector।
  3. एक .cpp file को gcc जैसे C compiler से C mode में compile करना और #include <iostream> या std::cout पर errors पाना।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.