J
jesse
I am frustrated by class specialization. i don't
think it helps me a lot.
suppose we have
template <class T>
class Talkative
{
T& t;
public:
Talkative( T& obj ) :
t( obj ) {
};
~Talkative(){};
void talk(){t.talk();};
void sing(){t.sing();};
void whisper(){t.whisper();};
};
//through class specialization , i want:
// 1) inherit the sing() from the base template class;
// 2) specialization the talk();
// 3) and add a new function bark();
template <>
class Talkative<Dog>
{
}
then in the declaration of
template <> class Talkative<Dog>, i need to re-write
everthing(code) that are already in the templates.
from constructor, destructor, copy-structor,
sing(), class variables t.
what a pity? is there any way to avoid this?
i was so frustrated by this issue!
(class member specialization doesn't fit here, since
i need to add a new function bark(); )
If you have good thoughts, could you please share with me.
thanks!
jesse
think it helps me a lot.
suppose we have
template <class T>
class Talkative
{
T& t;
public:
Talkative( T& obj ) :
t( obj ) {
};
~Talkative(){};
void talk(){t.talk();};
void sing(){t.sing();};
void whisper(){t.whisper();};
};
//through class specialization , i want:
// 1) inherit the sing() from the base template class;
// 2) specialization the talk();
// 3) and add a new function bark();
template <>
class Talkative<Dog>
{
}
then in the declaration of
template <> class Talkative<Dog>, i need to re-write
everthing(code) that are already in the templates.
from constructor, destructor, copy-structor,
sing(), class variables t.
what a pity? is there any way to avoid this?
i was so frustrated by this issue!
(class member specialization doesn't fit here, since
i need to add a new function bark(); )
If you have good thoughts, could you please share with me.
thanks!
jesse