main()
его подключить раньше остальных:#ifndef MAIN_H
#define MAIN_H
#include "Info.h"
#include "Core.h"
#endif // MAIN_H
#include "main.h"
int main() {
Core core = Core::get_instance();
if (core.code_work() == code::WORK) {
core.loop();
}
int code_work = core.code_work();
core.terminate();
return code_work;
}
#ifndef INFO_H
#define INFO_H
#include <string>
namespace Info {
extern const std::string TITLE;
extern const unsigned VER_MAJOR;
extern const unsigned VER_MINOR;
extern const unsigned VER_PATCH;
extern const std::string VERSION;
extern const std::string LOCATION_SETTINGS_FILE;
}
#endif // INFO_H
#include "Info.h"
namespace Info {
const std::string TITLE = "Project";
const unsigned VER_MAJOR = 0;
const unsigned VER_MINOR = 0;
const unsigned VER_PATCH = 1;
const std::string VERSION = std::to_string(VER_MAJOR) + "." + std::to_string(VER_MINOR) + "." + std::to_string(VER_PATCH);
const std::string LOCATION_SETTINGS_FILE = "C:/Users/User/Documents/My Games/" + TITLE + "/";
}
#include <iostream>
#include <fstream>
#include <filesystem>
class Logger {
public:
Logger();
template <class T>
Logger& operator<<(const T& info);
Logger& operator<<(std::ostream& (*manipulator)(std::ostream&));
private:
static bool is_create;
};
Logger::Logger() {
if (!is_create) {
std::filesystem::remove("Logger.txt");
is_create = true;
}
}
template <class T>
Logger& Logger::operator<<(const T& info) {
std::cout << info;
std::ofstream file("Logger.txt", std::ios_base::out | std::ios_base::app);
if (file.is_open()) {
file << info;
}
file.close();
return *this;
}
Logger& Logger::operator<<(std::ostream& (*manipulator)(std::ostream&)) {
std::cout << manipulator;
std::ofstream file("Logger.txt", std::ios_base::out | std::ios_base::app);
if (file.is_open()) {
file << manipulator;
}
file.close();
return *this;
}
bool Logger::is_create = false;