E
E
Eduard Matveev2018-05-30 10:48:39
OOP
Eduard Matveev, 2018-05-30 10:48:39

Prototype pattern or copy constructor?

What is preferable to use?
Or in what cases a pattern, and in what cases a constructor?
And what, in fact, is their difference (except for the implementation), based on which, you can decide when, where and which of them to use?
Forgive me if this is a stupid question, because I just started to study patterns.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
d-stream, 2018-05-30
@d-stream

A pattern is simply a "typical programming technique". And the constructor is already from the programming itself.
For example, a programming pattern (rather a style) can be the mandatory implementation of constructors without parameters, or vice versa.

V
Vyacheslav, 2018-05-30
@Nirail

Pattern (Design pattern / Design pattern) - as the name implies, this is an approach to designing classes / architecture, etc. and in different languages ​​can be implemented using different language tools.
For example, the "Prototype" pattern can be implemented in C++ using the copy constructor.
Templates allow you to effectively solve typical problems that arise when thinking through the code architecture, up to the moment of writing the code directly, while the task is not to "fit" the task into the templates, but to simplify the solution of the problem using templates.
Thus, the choice between a template or a constructor is, for the most part, not correct.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question