# 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;
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lifeexe-art.gitbook.io/game-engine.-hardcore-series/lectures/05.-c++-build-process.-linker.-forward-declaration/code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
