Originally Posted by
laserlight
I note that if you want to disable the copy and move constructors, then you probably should disable the copy and move assignment operators too.
You mean like this?
Code:
Engine& operator=(const Engine&) = delete;
Engine& operator=(Engine&&) = delete;
The problem I had is if I put this in engine.h
Code:
#pragma once
#include<memory>
struct Engine;
std::unique_ptr<Engine> ForgeEngine(int id, int mounts);
and this in engine.cpp
Code:
#include "engine.h"
struct Engine
{
const int Id;
const int Mounts;
constexpr Engine(int id, int mounts) : Id(id), Mounts(mounts) {}
~Engine() = default;
Engine(const Engine&) = delete;
Engine(Engine&&) = delete;
};
std::unique_ptr<Engine> ForgeEngine(int id, int mounts)
{
return std::make_unique<Engine>(id, mounts);
}
I get these errors:
Error C2338 can't delete an incomplete type
Warning C4150 deletion of pointer to incomplete type 'Engine'; no destructor called
follows by
Error C2027 use of undefined type 'Engine'