M
M
Max Suprunenko2015-10-10 09:14:51
C++ / C#
Max Suprunenko, 2015-10-10 09:14:51

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

1 answer(s)
M
MiiNiPaa, 2015-10-10
@msuprunenko

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 question

Ask a Question

731 491 924 answers to any question