This question is solved, just re-add the cpp file with the implementations to the project.
I am currently working on a Timer with RAII functionality and I came across an 'unresolved external symbol' error for both constructor and destructor. Am I missing something?
main.cpp:
#include "Timer.h"
#include "File.h"
int main()
{
RAIITimer timer;
File f{"test.txt", true};
for(int i{1000000}; i > 0; i--)
{
f.write("example\n");
}
}
Timer.h:
#pragma once
#include <chrono>
#include "Types.h"
using hr_clock = std::chrono::high_resolution_clock;
class RAIITimer
{
public:
RAIITimer(conststrref name = "Test");
~RAIITimer();
private:
hr_clock::time_point m_start;
hr_clock::time_point m_end;
std::string m_name;
};
Timer.cpp:
#include "Timer.h"
#include "OutUtils.h"
using std::chrono::milliseconds;
RAIITimer::RAIITimer(conststrref name)
: m_name {name}
{
m_start = hr_clock::now();
}
RAIITimer::~RAIITimer()
{
m_end = hr_clock::now();
double duration = std::chrono::duration_cast<milliseconds>(m_end - m_start).count();
logging::log(m_name + " finished in " + std::to_string(duration) + "ms");
}
I am using Visual Studio 2017. Any help is appreciated.