vendredi 24 mars 2017

Define methods in template class in c++

I am making a template class which has variable template arguments. However, when I define and call a method, my compiler says the method is not defined.

template <class T, class... Args>
class Params {
private:
    vector<void*> params;
    int n;

    void initializeParam(T a, Args... args) {
        params[i] = (void*)&a;
        n++;
        initializeParam(args...);
    }

    void initializeParam() {}

public:
    Params(T a, Args... args) : params(vector<void*>(sizeof...(Args)) {
        n = 0;
        initializeParam(a, args...); // Compiler -> initializeParam is not defined
    }
};

Can you tell me why?

Aucun commentaire:

Enregistrer un commentaire