vault backup: 2026-04-16 08:33:48

This commit is contained in:
Jan Meyer
2026-04-16 08:33:48 +02:00
parent 9db4f43b39
commit 0d4f07c5bc
2 changed files with 32 additions and 21 deletions

View File

@@ -22,15 +22,39 @@ C approach of defining a Pokemon:
```C
typedef struct {
int exp;
int level;
int attack;
unsigned int hp;
char name[];
int defense;
int speed;
int hp;
} Pokemon;
void upgrade(*Pokemon p, int gainedExp) {
p->exp += gainedExp;
if (p->exp >= 4000) {
p->exp -= 4000;
p->level += 1;
}
}
```
In C++ we use classes:
```C++
class Pokemon() {
class Pokemon {
public: // visibility modifier
int exp;
int level;
int attack;
int defense;
int speed;
int hp;
void upgrade(int gainedExp) {
exp += gainedExp;
if (exp >= 4000) {
exp -= 4000;
level += 1;
}
}
}
```