Hello, First of all thank you for taking time to help.
I recently started playing around with templates and singletons. I'm trying to make something like Unity's Debug.Log but in C++. Starting with simple things like cout. Unfortunately I got stuck and with all the googling I can't seem to find how to solve this issue without not making class singleton. Maybe there is better way of doing this?
//Console.h
#pragma once
#include <iostream>
class Console
{
private:
Console() {}
~Console() {}
public:
static Console& instance()
{
static Console INSTANCE;
return INSTANCE;
}
template <class T>
void Print(T arg);
};
//Console.cpp
#include "Console.h"
template <class T>
void Console::Print(T arg)
{
std::cout << arg.c_str() << std::endl;
}
//main.cpp
#include "Console.h"
int main(int argc, char *argv[])
{
Console::instance().Print(5);
return 0;
}
The error is: