D
D
Dmitry Shcherbakov2019-02-18 11:52:51
C++ / C#
Dmitry Shcherbakov, 2019-02-18 11:52:51

How to make a competent decomposition of OOP?

I was faced with the task of implementing an SD Stack on an array. Since I'm just getting into OOP, now I need to take classes as structures. And it is necessary to break my task into 5 or more structures. Can you please tell me how to split the implementation of the stack on an array into five objects?? It doesn't even cross my mind.)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2019-02-18
@res2001

A stack, of course, can be done on an array, but usually it is done on a list.
For the stack itself, 1-2 structures/classes are usually enough: The stack class and the stack node class.
For the rest, you can come up with an arbitrary simple inheritance hierarchy so that objects of these classes can be stacked by reference / pointer to the base class.
Modules are files:
1. main code - put main() here, perhaps some auxiliary functions.
2. and 3. standard splitting of C++ classes into header (.h) and implementation (.cpp).
Because there are at least 5 classes, then it’s wise to make headings and implementations for each class, but in your case you can put everything in 2 files. Though I would select a stack in separate "modules".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question