G
g3rc4n
is it possible to do something like this
template<class T, class FUN>
void foo(T& t, const FUN& f){
f(t);
}
template<class T, class FUN>
void fooo(T& t, const FUN& f){
t->f();
}
struct base{
virtual ~base(){}
virtual void say()=0;
};
struct dir : public base{
void say(){
std::cout << "hi" << std::endl;
}
};
void bar(){
base* ptr = new dir;
foo(ptr,std::mem_fun(base::say));
delete ptr;
}
or are virtual functons something that templates can't handle?
template<class T, class FUN>
void foo(T& t, const FUN& f){
f(t);
}
template<class T, class FUN>
void fooo(T& t, const FUN& f){
t->f();
}
struct base{
virtual ~base(){}
virtual void say()=0;
};
struct dir : public base{
void say(){
std::cout << "hi" << std::endl;
}
};
void bar(){
base* ptr = new dir;
foo(ptr,std::mem_fun(base::say));
delete ptr;
}
or are virtual functons something that templates can't handle?