N
naruto
Hi all,
I got an compile error saying "static variables should be init. at
point of declaration" when I try to the following:
// test.h
template<typename T>
class Callback
{
public:
typedef void (T::*F)();
Callback( T& t, F f ) : t_(&t), f_(f) { }
void operator()() const { (t_->*f_)(); }
static c_func() { (t_->*f_); }
private:
static T* t_;
F f_;
};
// test.cxx
#include "test.h"
template<typename T>
T* Callback<T>::t_ = 0;
int main()
{
}
Is there a way to fix this? I have a function that only takes in
function pointer and I would like to create a c_func() to simulate
this.
Thanks,
Naruto
I got an compile error saying "static variables should be init. at
point of declaration" when I try to the following:
// test.h
template<typename T>
class Callback
{
public:
typedef void (T::*F)();
Callback( T& t, F f ) : t_(&t), f_(f) { }
void operator()() const { (t_->*f_)(); }
static c_func() { (t_->*f_); }
private:
static T* t_;
F f_;
};
// test.cxx
#include "test.h"
template<typename T>
T* Callback<T>::t_ = 0;
int main()
{
}
Is there a way to fix this? I have a function that only takes in
function pointer and I would like to create a c_func() to simulate
this.
Thanks,
Naruto