J
jiake2007
Hi all,
I'm trying to write a template class that calls a function from one of
its template parameters:
template <class T>
class Foo
{
public:
Foo(T t): t(t) {}
void doFoo() {
t.doTheStuff();
}
private:
T t;
};
The problem is: t.doTheStuff() obviously works only if T is non-
pointer, and otherwise it has to be t->doTheStuff().
My question is: is there a way to implement a template class that
would work with all types regardless of if T is a pointer or not?
Thanks all,
-J
I'm trying to write a template class that calls a function from one of
its template parameters:
template <class T>
class Foo
{
public:
Foo(T t): t(t) {}
void doFoo() {
t.doTheStuff();
}
private:
T t;
};
The problem is: t.doTheStuff() obviously works only if T is non-
pointer, and otherwise it has to be t->doTheStuff().
My question is: is there a way to implement a template class that
would work with all types regardless of if T is a pointer or not?
Thanks all,
-J