I am currently new to C++ in the working world (learnt C++ academically). This is my first job where C++ is the base requirement.
May I ask -
- When do I use a template for a class?
- Is there any ideal or good practices that uses a template in a derived class, where the base class does not inherit any templates?
For example:
class Base {};
<typename T>
class Derived : public Base {};
The reason why I need to inherit from a base is because I need to store objects where it can be referenced from the base, and thereafter have a common factory method where I can pull information out.
Aucun commentaire:
Enregistrer un commentaire