-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcppmodule1.html
165 lines (151 loc) · 7.81 KB
/
cppmodule1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="javamodule.css">
<title>C++ Module 1 - Introduction to C++</title>
<style>
.video-button {
display: inline-block;
margin: 15px 0;
padding: 10px 20px;
background-color: #007BFF;
color: #fff;
text-align: center;
text-decoration: none;
border-radius: 5px;
transition: background-color 0.3s ease;
}
.video-button:hover {
background-color: #0056b3;
}
.video-container {
margin: 20px 0;
}
footer {
text-align: center;
margin-top: 30px;
padding: 20px 0;
background-color: #f1f1f1;
}
h2 {
color: #007BFF;
}
</style>
</head>
<body>
<header>
<h1>C++ Module 1: Introduction to C++</h1>
<nav>
<ul>
<li><a href="cppmodule1.html">Module 1</a></li>
<li><a href="cppmodule2.html">Module 2</a></li>
<li><a href="cppmodule3.html">Module 3</a></li>
</ul>
</nav>
</header>
<div class="container">
<h2>1. What is C++?</h2>
<p>
C++ is a powerful, high-performance, general-purpose programming language that was developed by <strong>Bjarne Stroustrup</strong> in 1983 as an extension of the C programming language. It supports both procedural and object-oriented programming paradigms, making it versatile for various applications such as game development, system software, and applications requiring high performance.
</p>
<div class="video-container">
<a href="https://youtu.be/SQHREey_Yuc?si=nv0-Lub9NVY1jW0n" target="_blank" class="video-button">Watch: What is C++?</a>
</div>
<h2>2. History and Evolution of C++</h2>
<p>
Originally named "C with Classes," C++ introduced object-oriented concepts to the C language. Over the years, it has evolved through several standards, including C++98, C++03, C++11, C++14, C++17, and the latest C++20. Each new version has introduced features that enhance the language's capabilities and ease of use, such as lambda expressions, smart pointers, and type inference.
</p>
<div class="video-container">
<a href="https://youtu.be/brqRL_t0RmM?si=RrnPRjQtKDOaEx0o" target="_blank" class="video-button">Watch: History and Evolution of C++</a>
</div>
<h2>3. Features of C++</h2>
<p>C++ provides a rich set of features that contribute to its versatility:</p>
<ul>
<li><strong>Object-Oriented Programming</strong>: Supports concepts like classes, inheritance, and polymorphism, allowing for code reusability and better organization.</li>
<li><strong>Low-level Manipulation</strong>: Offers control over hardware and memory, making it suitable for system programming and embedded systems.</li>
<li><strong>Standard Template Library (STL)</strong>: A powerful library that provides generic classes and functions for data structures and algorithms.</li>
<li><strong>Platform Independence</strong>: C++ code can be compiled on various platforms with minimal changes, promoting cross-platform development.</li>
<li><strong>Multi-Paradigm Support</strong>: Supports procedural, object-oriented, and generic programming, giving developers flexibility in their coding style.</li>
</ul>
<div class="video-container">
<a href="https://youtu.be/MDJ9uEHDhfU?si=eLI1PnT5I_OCxzWO" target="_blank" class="video-button">Watch: Features of C++</a>
</div>
<h2>4. Setting Up C++ Development Environment</h2>
<p>
To begin programming in C++, you'll need a <strong>compiler</strong> and an <strong>IDE (Integrated Development Environment)</strong>. Commonly used compilers include GCC (GNU Compiler Collection) for Linux and MinGW for Windows. Popular IDEs like <strong>Code::Blocks, Visual Studio, and CLion</strong> provide user-friendly interfaces that simplify coding, debugging, and project management.
</p>
<div class="video-container">
<a href="https://youtu.be/e840YAaK620?si=z8THNViZWoLxIZ4D" target="_blank" class="video-button">Watch: Setting Up C++ Environment</a>
</div>
<h2>5. Basic Structure of a C++ Program</h2>
<p>
A C++ program typically consists of functions and classes. Every C++ program must have a <code>main()</code> function, which serves as the entry point of the program. Below is the basic structure of a simple C++ program:
</p>
<pre><code>
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!";
return 0;
}
</code></pre>
<p>In this example:</p>
<ul>
<li><code>#include <iostream></code>: Includes the input-output stream library for handling input and output operations.</li>
<li><code>using namespace std;</code>: Allows access to standard library features without prefixing with <code>std::</code>.</li>
<li><code>int main()</code>: The main function where execution begins.</li>
<li><code>cout</code>: Used for outputting data to the console.</li>
</ul>
<h2>6. Writing Your First C++ Program</h2>
<p>
Let’s write a simple program that prints "Hello, C++!" to the console. This example will help you understand C++ syntax and how to compile and run your code.
</p>
<pre><code>
#include <iostream>
using namespace std;
int main() {
cout << "Hello, C++!" << endl;
return 0;
}
</code></pre>
<p>To compile and run the program:</p>
<ol>
<li><strong>Open your IDE</strong> and create a new project.</li>
<li><strong>Copy and paste</strong> the code into the main file.</li>
<li><strong>Compile the code</strong> using the "Build" or "Compile" option in your IDE.</li>
<li><strong>Run the executable</strong> to see the output in the console.</li>
</ol>
<h2>7. Testing Your Knowledge</h2>
<p>Once you've learned the basics of C++, it's important to test your understanding. Below are some questions to challenge your knowledge:</p>
<ol>
<li>What is the output of the following code?
<pre><code>cout << 5 + 2 * 3;</code></pre>
a) 11<br>
b) 21<br>
c) 15<br>
d) 17<br>
</li>
<li>Which of the following is not a valid data type in C++?
<pre><code>a) int<br>b) float<br>c) char<br>d) text</code></pre>
a) int<br>
b) float<br>
c) char<br>
d) text<br>
</li>
<li>What does the 'return 0;' statement indicate in the <code>main()</code> function?
<pre><code>a) The program ran successfully<br>b) The program encountered an error<br>c) The program has finished compiling<br>d) None of the above</code></pre>
a) The program ran successfully<br>
b) The program encountered an error<br>
c) The program has finished compiling<br>
d) None of the above<br>
</li>
</ol>
<p>Feel free to research the answers online or discuss them with your classmates!</p>
<footer>
<p>© 2024 Code Wiz - Learn C++ Step by Step</p>
</footer>
</div>
</body>
</html>