Answer the question
In order to leave comments, you need to log in
Virtual function or template for c++ polymorphism. What is better and more convenient?
Virtual function or template for c++ polymorphism. What is better and more convenient?
Answer the question
In order to leave comments, you need to log in
They serve different purposes. Templates can only be used for static polymorphism: when the types of the operands are known at compile time. If you need to change the behavior at runtime (if you use pointers / references to the base class), then virtual functions are indispensable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question