# Code

### Math

```cpp
// Math.h
#pragma once
#include <vector>

#ifdef _EXPORTING
#define MATH_API    __declspec(dllexport)
#elif _IMPORTING
#define MATH_API    __declspec(dllimport)
#else
#define MATH_API
#endif

namespace LifeExe {
    MATH_API int max(int x, int y);
    MATH_API int factorial(int n);
    MATH_API int sum(int n);
    MATH_API std::vector<int> createLargeVector();
}

```

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

namespace LifeExe {
    int max(int x, int y)
    {
        return x > y ? x : y;
    }

    int factorial(int n)
    {
        return n <= 1 ? 1 : n * factorial(n - 1);
    }

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

    std::vector<int> createLargeVector()
    {
        std::vector<int> vec(100000000, 12);
        return vec;
    }
}

```

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

#ifdef _EXPORTING
#define GAME_API    __declspec(dllexport)
#elif _IMPORTING
#define GAME_API    __declspec(dllimport)
#else
#define GAME_API
#endif

class Weapon;

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

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

```

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

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

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

```

### Main

```cpp
// main.cpp

#include "Character.h"
#include "Math.h"
#include <iostream>

int main() {
    using namespace LifeExe;

    const int result1 = max(10, 20);
    const int result2 = factorial(10);
    const int result3 = sum(10);
    const int result = result1 + result2 + result3;
    std::vector<int> vec = createLargeVector();

    const Character character("Nux");

    std::cout << result << std::endl;
    std::cout << vec.size() << std::endl;
    std::cin.get();

    return 0;
}

```

### PCH

```cpp
// pch.h

#pragma once

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <memory>
#include <thread>
#include "Math.h"
#include "Character.h"

```

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

```
