C++ Passing a class as a parameter

You can use templates to accomplish something similar (but not exactly that):

template<class T>
void MyFunction()
{
    T *tmp = new T();
}

and call it with MyFunction<MyClassName>().

Note that this way, you can’t use a “variable” in place of T. It should be known at compile time.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)