@@ -26,7 +26,7 @@ The definition of a new `class` can be seen in the following example.
2626Notice the ` ; ` after the definition.
2727
2828``` cpp
29- class Wizzard {
29+ class Wizard {
3030 public: // from here on all members are accessible publicly
3131 int cast_spell() { // defines the public member function cast_spell
3232 return damage;
@@ -43,7 +43,7 @@ Take a look at `damage` inside the `cast_spell` function.
4343You cannot read or change `private` members outside of the class:
4444
4545```cpp
46- Wizzard silverhand{};
46+ Wizard silverhand{};
4747// calling the `cast_spell` function is okay, it is public:
4848silverhand.cast_spell();
4949// => 5
@@ -64,12 +64,12 @@ A class can have several constructors.
6464This is useful if you do not always have a need to set all variables.
6565
6666``` cpp
67- class Wizzard {
67+ class Wizard {
6868 public:
69- Wizzard (std::string new_name) {
69+ Wizard (std::string new_name) {
7070 name = new_name;
7171 }
72- Wizzard (std::string new_name, int new_damage) {
72+ Wizard (std::string new_name, int new_damage) {
7373 name = new_name;
7474 damage = new_damage;
7575 }
@@ -81,8 +81,8 @@ class Wizzard {
8181 int damage{5};
8282};
8383
84- Wizzard el{"Eleven"}; // deals 5 damage
85- Wizzard vecna{"Vecna", 50}; // deals 50 damage
84+ Wizard el{"Eleven"}; // deals 5 damage
85+ Wizard vecna{"Vecna", 50}; // deals 50 damage
8686```
8787
8888Constructors are a big topic and have many nuances.
@@ -101,6 +101,6 @@ By default, everything in a `class` is `private`.
101101Structs, on the other hand, are `public` until defined otherwise.
102102Conventionally, the `struct` keyword is often used for **data-only structures**.
103103The `class` keyword is preferred for objects that need to ensure certain properties.
104- Such an invariant could be that the `damage` of your `Wizzard ` `class` cannot turn negative.
104+ Such an invariant could be that the `damage` of your `Wizard ` `class` cannot turn negative.
105105The `damage` variable is private and any function that changes the damage would ensure the invariant is preserved.
106106~~~~
0 commit comments