> For the complete documentation index, see [llms.txt](https://lifeexe-art.gitbook.io/game-engine.-hardcore-series/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lifeexe-art.gitbook.io/game-engine.-hardcore-series/lectures/05.-c++-build-process.-linker.-forward-declaration/code.md).

# Code

### Math

```cpp
// Math.h
#pragma once

int max(int x, int y);
int factorial(int n);
int sum(int n);

```

<pre class="language-cpp"><code class="lang-cpp">// Math.cpp
<strong>int max(int x, int y)
</strong>{
    return x > y ? x : y;
}

int factorial(int n)
{
    return n &#x3C;= 1 ? 1 : n * factorial(n - 1);
}

int sum(int n)
{
    return n &#x3C;= 0 ? 0 : n + sum(n - 1);
}

</code></pre>

### Weapon

```cpp
// Weapon.h
#pragma once

class Weapon
{
public:
    Weapon();
    void fire();

private:
    int m_bullets{ 23 };
};

```

```cpp
// Weapon.cpp
#include "Weapon.h"

Weapon::Weapon()
{

}

void Weapon::fire()
{
    if (m_bullets <= 0) return;
    --m_bullets;
}

```

### Character

```cpp
// Character.h
#pragma once

class Weapon;

class Character
{
public:
    Character(const char* name);
    ~Character();

    void f1(Weapon*);
    void f2(Weapon&); 
    void f3(const Weapon&);
    Weapon f4();
    void f5(Weapon);

private:
    const char* m_name;
    Weapon* m_weapon;
};

```

```cpp
// Character.cpp
#include "Character.h"
#include "Weapon.h"
#include <iostream>

Character::Character(const char* name) : m_name(name)
{
    m_weapon = new Weapon();
    m_weapon->fire();

    std::cout << sizeof(Weapon) << std::endl;
    std::cout << sizeof(Weapon*) << std::endl;
    std::cin.get();
}

Character::~Character()
{
    delete m_weapon;
    m_weapon = nullptr;
}

void Character::f1(Weapon*)
{
}

void Character::f2(Weapon&)
{
}

void Character::f3(const Weapon&)
{
}

Weapon Character::f4()
{
    return Weapon();
}

void Character::f5(Weapon)
{
}

```

### Main

```cpp
// main.cpp
#include "Character.h"

int main() {
    const Character character("Nux");
    // int counter = 10;
    // counter %= 0;
    return 0;
}

```
