Skip to content

Commit

Permalink
Just add code to pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolasan committed Jul 28, 2024
1 parent 21030d9 commit 0941887
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 3 deletions.
23 changes: 22 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,28 @@
"ranges": "cpp",
"filesystem": "cpp",
"text_encoding": "cpp",
"*.inc": "cpp"
"*.inc": "cpp",
"ios": "cpp",
"locale": "cpp",
"queue": "cpp",
"stack": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"__nullptr": "cpp"
},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
10 changes: 9 additions & 1 deletion src/basics/constness.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,40 @@

## Arrays and pointers

### Intact values

Values of the array cannot be changed. But array itself can be assigned

```cpp
{{#include ../../basics/constness/const-1.cpp}}
```
### Intact pointer
This preserves the pointer but not the values
```cpp
{{#include ../../basics/constness/const-2.cpp}}
```

### Initialize only once

It must be assigned only once

```cpp
{{#include ../../basics/constness/const-3.cpp}}
```
### Read-only
Here's the absolute read-only version
```cpp
{{#include ../../basics/constness/const-4.cpp}}
```


## When function call changes the pointer
## When function changes the pointer

Wrong

Expand Down
13 changes: 13 additions & 0 deletions src/basics/files.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# Files

## Get file content

```cpp
std::ifstream in(filename, std::ios::in | std::ios::binary);
if (!in) {
std::cerr << "could not open " << filename << std::endl;
return 1;
}
std::ostringstream contents;
contents << in.rdbuf();
std::string ogg_data = contents.str();
```
4 changes: 4 additions & 0 deletions src/basics/leaks/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Leaks

```cpp
{{#include ../../../basics/pointing_arguments/cleaning.cpp}}
```
4 changes: 4 additions & 0 deletions src/basics/leaks/containers.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Raw pointers

```cpp
{{#include ../../../basics/raw_pointers/raw-pointer-container.cpp}}
```
1 change: 0 additions & 1 deletion src/basics/leaks/map.md

This file was deleted.

4 changes: 4 additions & 0 deletions src/basics/leaks/stdmap.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Weird Map

```cpp
{{#include ../../../basics/weird_map/weird-map.cpp}}
```
22 changes: 22 additions & 0 deletions src/basics/pointers/arguments.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# Pointing arguments

```cpp
{{#include ../../../basics/pointing_arguments/pointing.cpp}}
```
## C style
```cpp
{{#include ../../../basics/pointing_arguments/c-style.cpp}}
```

## By reference

```cpp
{{#include ../../../basics/pointing_arguments/by-reference.cpp}}
```
## C++ style
```cpp
{{#include ../../../basics/pointing_arguments/cpp-style.cpp}}
```

1 comment on commit 0941887

@mikolasan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.