Skip to content

Commit 07d71e1

Browse files
modifications to c++ post
1 parent cfca64d commit 07d71e1

File tree

44 files changed

+377
-1384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+377
-1384
lines changed

content/post/cplusplus-working.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ tags = [
1010

1111
I was just learning about the C++ fundamentals from **The Cherno** C++ playlist and thought of making notes on it. Added reference at the bottom.
1212

13-
**What’s cmake?**
13+
### What’s cmake?
1414

15-
CMake is an open-source, cross-platform build system generator. It doesn’t build software directly—it generates build files (like Makefiles, Ninja build files, or Visual Studio project files) based on the instructions you give it in `CMakeLists.txt`.
15+
CMake is an open-source, cross-platform build system generator. It doesn’t build software directly—it generates build files (like Makefiles, Ninja build files, or Visual Studio project files) based on the instructions present in <mark>CMakeLists.txt</mark>.
1616

1717
```cpp
1818
cmake_minimum_required (VERSION 3.5)
@@ -27,7 +27,7 @@ file(GLOB source_files "${source_dir}/*.cpp")
2727
add_executable (HelloWorld ${source_files})
2828
```
2929
30-
This ``CMakeLists.txt`` file is a CMake build script that defines how to build a simple C++ project named `HelloWorld`.
30+
This `CMakeLists.txt` file is a CMake build script that defines how to build a simple C++ project named `HelloWorld`.
3131
3232
- In the above code, it specifies that minimum version of cmake should be 3.5.
3333
- The name of the project would be ‘HelloWorld’.
@@ -36,38 +36,38 @@ This ``CMakeLists.txt`` file is a CMake build script that defines how to build a
3636
- Files with `.cpp` extension will be stored into the source directory.
3737
- An executable with the name ‘HelloWorld’ is to be created on build using the .cpp files in source directory.
3838
39-
A [`build.sh`](http://build.sh) file is created that contains the cmake command to configure the build environment. It would generate Makefiles to use with the IDE (here CodeLite).
39+
A <mark>build.sh</mark> file is created that contains the cmake command to configure the build environment. It would generate Makefiles to use with the IDE (here CodeLite).
4040
4141
```cpp
4242
cmake -G "CodeLite - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug
4343
```
4444

45-
**In a C program**
45+
### In a C program
4646

47-
There is a preprocessor statement `#include <iostream>`. Any line starting with a `#` would be a preprocessor statement. The `include` preprocessor will copy all the contents of the mentioned file (here iostream) directly into our program file. The preprocessor statement is executed before the compilation starts. Only `.cpp` files are compiled. The `.cpp` files are compiled into `.obj` files.
47+
There is a <mark>preprocessor</mark> statement `#include <iostream>`. Any line starting with a `#` would be a preprocessor statement. The <mark>include</mark> preprocessor will copy all the contents of the mentioned file (here iostream) directly into our program file. The preprocessor statement is executed before the compilation starts. Only `.cpp` files are compiled. The `.cpp` files are compiled into `.obj` files.
4848

49-
**Linker** is used to join all the `.obj` files into one executable file (`.exe` in Windows)
49+
<mark>**Linker**</mark> is used to join all the `.obj` files into one executable file (`.exe` in Windows)
5050

51-
We can just declare a function in our program, and call it in another function. The function declaration could be empty, it doesn’t need to be declared to compile successfully. The **compiler** doesn’t check if the function has been defined. Only during the runtime(build) would we get the error indicating that the function has no definition.
51+
We can just declare a function in our program, and call it in another function. The function declaration could be empty, it doesn’t need to be declared to compile successfully. The <mark>**compiler**</mark> doesn’t check if the function has been defined. Only during the runtime(build) would we get the error indicating that the function has no definition.
5252

5353
The `.obj` file is binary and not readable. It contains the machine code that CPU runs. We can create a `.asm` file from the `.cpp` file which contains assembly instructions.
5454

55-
After compilation, a process called Linking takes place. Linking finds all the symbols, functions, etc. in our project and link them together. Compilation happens on individual files separately.
55+
After compilation, a process called <mark>linking</mark> takes place. Linking finds all the symbols, functions, etc. in our project and link them together. Compilation happens on individual files separately.
5656

57-
Let’s say that we call a function A, which in turn calls a function B and function B is declared but not defined, we will get a linking error and not a compile error. If we do not call the function A, but it still exists and call the function B, we will still get the linking error. If we add static to the declaration of function A, and do not call it, we will not get the linking error.
57+
Let’s say that we call a function A, which in turn calls a function B and function B is declared but not defined, we will get a linking error and not a compile error. If we do not call the function A, but it still exists and call the function B, we will still get the linking error. If we add <mark>static</mark> to the declaration of function A, and do not call it, we will not get the linking error.
5858

59-
If we add **static** in any function declaration, then it means that the function is only declared for that particular file, and the linker will understand that.
59+
> If we add `static` in any function declaration, then it means that the function is only declared for that particular file.
6060
61-
So, the linker understands that the function A will only be used in the file where it is defined. It will see that function A is not being called, so it doesn’t matter whether the function B(which is being called inside function A) is defined or not. If the function is not declared as static, then there is a possibility that function A might get called in some other file, and for that the function B also needs to be defined.
61+
So, the linker understands that the function A will only be used in the file where it is defined. It will see that function A is not being called, so it doesn’t matter whether the function B (which is being called inside function A) is defined or not. If the function is not declared as static, then there is a possibility that function A might get called in some other file, and for that the function B also needs to be defined.
6262

63-
If we define a function inside a header file, and then include the same header file in two different `.cpp` files, we will get a linking error. It is because, including the header file means copying the contents of the header file to those two files, and meaning declaration of the function in two files.
63+
If we define a function inside a header file, and then include the same header file in two different `.cpp` files, we will get a linking error. It is because, including the header file means copying the contents of the header file, and here it means declaring the function in two files.
6464

65-
We can use `static` keyword while declaring the function in the header file. It will mean that the linking to the static function will be internal to the file calling it and separate files will have there own separate versions of the function.
65+
> We can use `static` keyword while declaring the function in the header file. It will mean that the linking to the static function will be internal to the file calling it and separate files will have there own separate versions of that function declared as static.
6666
67-
**References:**
67+
### References
6868

6969
- [TheCherno - Youtube](https://www.youtube.com/@TheCherno)
7070
- [How to setup C++ on Linux](https://www.youtube.com/watch?v=LKLuvoY6U0I&list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb&index=4&pp=iAQB)
7171
- [How C++ Works](https://www.youtube.com/watch?v=SfGuIVzE_Os&list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb&index=7)
7272
- [How the C++ Compiler Works](https://www.youtube.com/watch?v=3tIqpEmWMLI&list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb&index=6)
73-
- [How the C++ Linker Works](https://www.youtube.com/watch?v=H4s55GgAg0I&list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb&index=7)
73+
- [How the C++ Linker Works](https://www.youtube.com/watch?v=H4s55GgAg0I&list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb&index=7)

hugo.toml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ languageCode = 'en-us'
44
title = 'devplayer55221'
55
theme = 'hugo-paper'
66

7+
78
[params]
89
# color style
910
color = 'linen' # linen, wheat, gray, light
@@ -19,14 +20,18 @@ theme = 'hugo-paper'
1920
# rss = true # show rss icon
2021

2122
# misc
22-
disableHLJS = true # disable highlight.js
23-
disablePostNavigation = true # disable post navigation
24-
monoDarkIcon = true # show monochrome dark mode icon
25-
math = true # enable KaTeX math typesetting globally
26-
localKatex = false # use local KaTeX js/css instead of CDN
27-
favicon = "favicon.ico" # customize the default favicon
28-
appleTouchIcon = "apple-touch-icon.png" # customize the default Apple touch icon
23+
# disableHLJS = false # disable highlight.js
24+
# disablePostNavigation = true # disable post navigation
25+
# monoDarkIcon = false # show monochrome dark mode icon
26+
# math = true # enable KaTeX math typesetting globally
27+
# localKatex = false # use local KaTeX js/css instead of CDN
28+
# favicon = "favicon.ico" # customize the default favicon
29+
# appleTouchIcon = "apple-touch-icon.png" # customize the default Apple touch icon
2930

31+
[markup]
32+
[markup.goldmark]
33+
[markup.goldmark.renderer]
34+
unsafe = true
3035

3136
[menu]
3237

public/404.html

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,13 @@
3333
<meta name="author" content="devplayer55221" /><link rel="preload stylesheet" as="style" href="http://localhost:1313/main.min.css" />
3434

3535

36-
<link rel="preload" as="image" href="http://localhost:1313/theme.svg" />
36+
<link rel="preload" as="image" href="http://localhost:1313/theme.png" />
3737

3838

3939

4040
<link rel="preload" as="image" href="http://localhost:1313/twitter.svg" /><link rel="preload" as="image" href="http://localhost:1313/github.svg" /><link rel="preload" as="image" href="http://localhost:1313/linkedin.svg" />
4141

42-
<link
43-
rel="stylesheet"
44-
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
45-
integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI"
46-
crossorigin="anonymous"
47-
/>
48-
<script
49-
defer
50-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
51-
integrity="sha384-G0zcxDFp5LWZtDuRMnBkk3EphCK1lhEf4UEyEM693ka574TZGwo4IWwS6QLzM/2t"
52-
crossorigin="anonymous"
53-
></script>
54-
<script
55-
defer
56-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
57-
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
58-
crossorigin="anonymous"
59-
></script><script>
60-
document.addEventListener('DOMContentLoaded', () =>
61-
renderMathInElement(document.body, {
62-
63-
64-
delimiters: [
65-
{ left: '$$', right: '$$', display: true },
66-
{ left: '$', right: '$', display: false },
67-
],
68-
69-
throwOnError: false,
70-
}),
71-
);
72-
</script>
73-
42+
7443

7544

7645
<link
@@ -96,7 +65,7 @@
9665
>devplayer55221</a
9766
>
9867
<div
99-
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.svg)_left_center/cover_no-repeat] dark:invert dark:[background-position:right]"
68+
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.png)_left_center/_auto_theme('spacing.6')_no-repeat] [transition:_background-position_0.4s_steps(5)] dark:[background-position:right]"
10069
role="button"
10170
aria-label="Dark"
10271
></div>

public/about/index.html

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,44 +32,17 @@
3232
<meta name="author" content="mukund" /><link rel="preload stylesheet" as="style" href="http://localhost:1313/main.min.css" />
3333

3434

35-
<link rel="preload" as="image" href="http://localhost:1313/theme.svg" />
35+
<link rel="preload" as="image" href="http://localhost:1313/theme.png" />
3636

3737

3838

3939
<link rel="preload" as="image" href="http://localhost:1313/twitter.svg" /><link rel="preload" as="image" href="http://localhost:1313/github.svg" /><link rel="preload" as="image" href="http://localhost:1313/linkedin.svg" />
4040

41-
<link
42-
rel="stylesheet"
43-
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
44-
integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI"
45-
crossorigin="anonymous"
46-
/>
47-
<script
48-
defer
49-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
50-
integrity="sha384-G0zcxDFp5LWZtDuRMnBkk3EphCK1lhEf4UEyEM693ka574TZGwo4IWwS6QLzM/2t"
51-
crossorigin="anonymous"
52-
></script>
53-
<script
54-
defer
55-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
56-
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
57-
crossorigin="anonymous"
58-
></script><script>
59-
document.addEventListener('DOMContentLoaded', () =>
60-
renderMathInElement(document.body, {
61-
62-
63-
delimiters: [
64-
{ left: '$$', right: '$$', display: true },
65-
{ left: '$', right: '$', display: false },
66-
],
67-
68-
throwOnError: false,
69-
}),
70-
);
71-
</script>
72-
41+
<script
42+
defer
43+
src="http://localhost:1313/highlight.min.js"
44+
onload="hljs.initHighlightingOnLoad();"
45+
></script>
7346

7447

7548
<link
@@ -95,7 +68,7 @@
9568
>devplayer55221</a
9669
>
9770
<div
98-
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.svg)_left_center/cover_no-repeat] dark:invert dark:[background-position:right]"
71+
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.png)_left_center/_auto_theme('spacing.6')_no-repeat] [transition:_background-position_0.4s_steps(5)] dark:[background-position:right]"
9972
role="button"
10073
aria-label="Dark"
10174
></div>

public/archives/index.html

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,17 @@
2929
<meta name="author" content="devplayer55221" /><link rel="preload stylesheet" as="style" href="http://localhost:1313/main.min.css" />
3030

3131

32-
<link rel="preload" as="image" href="http://localhost:1313/theme.svg" />
32+
<link rel="preload" as="image" href="http://localhost:1313/theme.png" />
3333

3434

3535

3636
<link rel="preload" as="image" href="http://localhost:1313/twitter.svg" /><link rel="preload" as="image" href="http://localhost:1313/github.svg" /><link rel="preload" as="image" href="http://localhost:1313/linkedin.svg" />
3737

38-
<link
39-
rel="stylesheet"
40-
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
41-
integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI"
42-
crossorigin="anonymous"
43-
/>
44-
<script
45-
defer
46-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
47-
integrity="sha384-G0zcxDFp5LWZtDuRMnBkk3EphCK1lhEf4UEyEM693ka574TZGwo4IWwS6QLzM/2t"
48-
crossorigin="anonymous"
49-
></script>
50-
<script
51-
defer
52-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
53-
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
54-
crossorigin="anonymous"
55-
></script><script>
56-
document.addEventListener('DOMContentLoaded', () =>
57-
renderMathInElement(document.body, {
58-
59-
60-
delimiters: [
61-
{ left: '$$', right: '$$', display: true },
62-
{ left: '$', right: '$', display: false },
63-
],
64-
65-
throwOnError: false,
66-
}),
67-
);
68-
</script>
69-
38+
<script
39+
defer
40+
src="http://localhost:1313/highlight.min.js"
41+
onload="hljs.initHighlightingOnLoad();"
42+
></script>
7043

7144

7245
<link
@@ -92,7 +65,7 @@
9265
>devplayer55221</a
9366
>
9467
<div
95-
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.svg)_left_center/cover_no-repeat] dark:invert dark:[background-position:right]"
68+
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.png)_left_center/_auto_theme('spacing.6')_no-repeat] [transition:_background-position_0.4s_steps(5)] dark:[background-position:right]"
9669
role="button"
9770
aria-label="Dark"
9871
></div>

public/categories/index.html

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,13 @@
3333
<meta name="author" content="devplayer55221" /><link rel="preload stylesheet" as="style" href="http://localhost:1313/main.min.css" />
3434

3535

36-
<link rel="preload" as="image" href="http://localhost:1313/theme.svg" />
36+
<link rel="preload" as="image" href="http://localhost:1313/theme.png" />
3737

3838

3939

4040
<link rel="preload" as="image" href="http://localhost:1313/twitter.svg" /><link rel="preload" as="image" href="http://localhost:1313/github.svg" /><link rel="preload" as="image" href="http://localhost:1313/linkedin.svg" />
4141

42-
<link
43-
rel="stylesheet"
44-
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
45-
integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI"
46-
crossorigin="anonymous"
47-
/>
48-
<script
49-
defer
50-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
51-
integrity="sha384-G0zcxDFp5LWZtDuRMnBkk3EphCK1lhEf4UEyEM693ka574TZGwo4IWwS6QLzM/2t"
52-
crossorigin="anonymous"
53-
></script>
54-
<script
55-
defer
56-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
57-
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
58-
crossorigin="anonymous"
59-
></script><script>
60-
document.addEventListener('DOMContentLoaded', () =>
61-
renderMathInElement(document.body, {
62-
63-
64-
delimiters: [
65-
{ left: '$$', right: '$$', display: true },
66-
{ left: '$', right: '$', display: false },
67-
],
68-
69-
throwOnError: false,
70-
}),
71-
);
72-
</script>
73-
42+
7443

7544

7645
<link
@@ -96,7 +65,7 @@
9665
>devplayer55221</a
9766
>
9867
<div
99-
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.svg)_left_center/cover_no-repeat] dark:invert dark:[background-position:right]"
68+
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.png)_left_center/_auto_theme('spacing.6')_no-repeat] [transition:_background-position_0.4s_steps(5)] dark:[background-position:right]"
10069
role="button"
10170
aria-label="Dark"
10271
></div>

public/index.html

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,13 @@
3333
<meta name="author" content="devplayer55221" /><link rel="preload stylesheet" as="style" href="http://localhost:1313/main.min.css" />
3434

3535

36-
<link rel="preload" as="image" href="http://localhost:1313/theme.svg" />
36+
<link rel="preload" as="image" href="http://localhost:1313/theme.png" />
3737

3838

3939

4040
<link rel="preload" as="image" href="http://localhost:1313/twitter.svg" /><link rel="preload" as="image" href="http://localhost:1313/github.svg" /><link rel="preload" as="image" href="http://localhost:1313/linkedin.svg" />
4141

42-
<link
43-
rel="stylesheet"
44-
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
45-
integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI"
46-
crossorigin="anonymous"
47-
/>
48-
<script
49-
defer
50-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
51-
integrity="sha384-G0zcxDFp5LWZtDuRMnBkk3EphCK1lhEf4UEyEM693ka574TZGwo4IWwS6QLzM/2t"
52-
crossorigin="anonymous"
53-
></script>
54-
<script
55-
defer
56-
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
57-
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
58-
crossorigin="anonymous"
59-
></script><script>
60-
document.addEventListener('DOMContentLoaded', () =>
61-
renderMathInElement(document.body, {
62-
63-
64-
delimiters: [
65-
{ left: '$$', right: '$$', display: true },
66-
{ left: '$', right: '$', display: false },
67-
],
68-
69-
throwOnError: false,
70-
}),
71-
);
72-
</script>
73-
42+
7443

7544

7645
<link
@@ -96,7 +65,7 @@
9665
>devplayer55221</a
9766
>
9867
<div
99-
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.svg)_left_center/cover_no-repeat] dark:invert dark:[background-position:right]"
68+
class="btn-dark text-[0px] ltr:ml-4 rtl:mr-4 h-6 w-6 shrink-0 cursor-pointer [background:url(./theme.png)_left_center/_auto_theme('spacing.6')_no-repeat] [transition:_background-position_0.4s_steps(5)] dark:[background-position:right]"
10069
role="button"
10170
aria-label="Dark"
10271
></div>

0 commit comments

Comments
 (0)