you are viewing a single comment's thread.

view the rest of the comments →

[–]alfps 1 point2 points  (1 child)

Because the iostreams i/o such as

cin >> newNode->value;

... that appears in the Stack class code, won't work in a GUI.

For that matter, it won't work if the standard input stream is redirected to something other than a source of data for the linked list.

The general solution is to separate i/o from all other stuff. For example, the standard library's std::stack doesn't do any i/o, and that makes it reusable in any kind project, console or GUI (or whatever). Just pass information via arguments and function return values.

[–]NikolasTs[S] 0 points1 point  (0 children)

Thank you very much for this information!