Hi, I know re-inventing the wheel is not something that's popular but I just wanted to create basic data structures in C++ and improve my coding. If any of the folks can go through the code and let me know of modifications, I'd appreciate it greatly.
pop() has no protection from the stack being empty. If your intention is that pop() is only called from the destructor (which does have protection), then pop() should be private.
What's the value of topNode when the stack is empty? Since pop() is public, it's possible for the user to empty the stack.
What's the value of topNode->value after constructing MyStack?
IMO pop should return the value being popped as well and if there is nothing to pop then should throw some sort of exception so you can handle it accordingly.