M
Mike
I have a class temple which has to handle strings differently. Only a few
functions have to handle the string type differently. Is there anyway I can
do this without having two 'complete' classes, one generic and one for
strings only. I would just like to define the functions which are
different.
// Class Header example (there are other funcitons - this is just
// to show what I have done - and what I am trying to do.
tempate <class T>
class xList
{
public:
xList();
~xList();
T GetListVal();
void SetListVal( T );
private:
T *Ptr;
T Val;
};
tempate <>
class xList<std::string>
{
public:
xList();
~xList();
string GetListVal();
void SetListVal( string );
private:
string Val;
};
The only function that will be different is the 'string GetListVal()' - is
there anyway I can just define a special 'string' function for the
GetListVal() when the class is typed as string?
Thanks
Mike
functions have to handle the string type differently. Is there anyway I can
do this without having two 'complete' classes, one generic and one for
strings only. I would just like to define the functions which are
different.
// Class Header example (there are other funcitons - this is just
// to show what I have done - and what I am trying to do.
tempate <class T>
class xList
{
public:
xList();
~xList();
T GetListVal();
void SetListVal( T );
private:
T *Ptr;
T Val;
};
tempate <>
class xList<std::string>
{
public:
xList();
~xList();
string GetListVal();
void SetListVal( string );
private:
string Val;
};
The only function that will be different is the 'string GetListVal()' - is
there anyway I can just define a special 'string' function for the
GetListVal() when the class is typed as string?
Thanks
Mike