c++ - How to avoid defining the whole template class in header file -
i have class this:
template <typename t> class c { public: c(t t): t{t} {} void publicmethoda() { privatemethoda(); } void publicmethodb() {} void publicmethodc() {} // ... private: void privatemethoda() { t.call(); /* 1 place uses t member */ } void privatemethodb() {} // ... t t; };
in example need template field t
in 1 place (in privatemethoda
) , forces me define each method in header file (but not use t
member). how can avoid this? have ideas?
you can put not depend on t
in base class , inherit it. anyhow, fact class template, has many methods not depend on template parameter suggests putting stuff inside single class better belongs seperate ones.
Comments
Post a Comment