mardi 28 avril 2020

How can I write a Print method for variable arguments without templates?

int temp=10;
string tempStr="hello";
LOG("test num:", temp, ", str:", tempStr);

#define LOG(...) Logger::getInstance().Print(__VA_ARGS__)

I already know how I make Print using template. But I wonder that can I make Print without template? Is it impossible? Beacuse I want to make Print method from virtual function.

class Logger : public ILogger
{
public:
virtual void Print(...) override
{
// what should I do in here?
}
}

    class ILogger
    {
    public:
    virtual void Print(...) =0;
    }

Aucun commentaire:

Enregistrer un commentaire