R
Robert.Holic
Hi All (first time caller, long time listener),
I've stumbled across a problem that I have yet to figure out,
although Im sure I'll kick myself when I figure it out. Here it is:
I need to create a templated class that accepts any type. Easy
enough I though, like this:
template<typename Type>
class Foo
{
Type data;
Foo(Type d){ data = d);
~Foo(void){}
void SetData(Type d){ data = d; }
}
But what if the type is char*? Is there a way I can tell it is and
therefore strcpy into data instead of straight copy of the pointer so
that when the inputted string into SetData loses scope I can retain
it? Hopefully that makes sense. Thanks!
I've stumbled across a problem that I have yet to figure out,
although Im sure I'll kick myself when I figure it out. Here it is:
I need to create a templated class that accepts any type. Easy
enough I though, like this:
template<typename Type>
class Foo
{
Type data;
Foo(Type d){ data = d);
~Foo(void){}
void SetData(Type d){ data = d; }
}
But what if the type is char*? Is there a way I can tell it is and
therefore strcpy into data instead of straight copy of the pointer so
that when the inputted string into SetData loses scope I can retain
it? Hopefully that makes sense. Thanks!