SuperShinyEyes / simple-stack-cpp

0 stars 0 forks source link

Should I use smart pointers instead of raw pointers? #2

Open SuperShinyEyes opened 3 weeks ago

SuperShinyEyes commented 3 weeks ago

I used only raw pointers. Should I replace them with smart pointers? https://github.com/SuperShinyEyes/simple-stack-cpp/blob/fdca30da7a6aee60a802ba726d19f30a884ce0ba/include/simple_stack.h#L75-L77

https://github.com/SuperShinyEyes/simple-stack-cpp/blob/fdca30da7a6aee60a802ba726d19f30a884ce0ba/include/simple_stack.h#L138-L145

https://github.com/SuperShinyEyes/simple-stack-cpp/blob/fdca30da7a6aee60a802ba726d19f30a884ce0ba/include/simple_stack.h#L198-L204

https://github.com/SuperShinyEyes/simple-stack-cpp/blob/fdca30da7a6aee60a802ba726d19f30a884ce0ba/include/simple_stack.h#L207-L211

https://github.com/SuperShinyEyes/simple-stack-cpp/blob/fdca30da7a6aee60a802ba726d19f30a884ce0ba/include/simple_stack.h#L312-L322

puputskov commented 3 weeks ago

If you feel like it as that is what most modern C++ developers do prefer. Also it should remove the need to deallocate the memory manually using delete

puputskov commented 3 weeks ago

Why are you doing this?

https://github.com/SuperShinyEyes/simple-stack-cpp/blob/fdca30da7a6aee60a802ba726d19f30a884ce0ba/include/simple_stack.h#L174

https://github.com/SuperShinyEyes/simple-stack-cpp/blob/fdca30da7a6aee60a802ba726d19f30a884ce0ba/include/simple_stack.h#L166

https://github.com/SuperShinyEyes/simple-stack-cpp/blob/fdca30da7a6aee60a802ba726d19f30a884ce0ba/include/simple_stack.h#L187

instead of array [this->numberOfElements], array [this->numberOfElements - 1]?

SuperShinyEyes commented 3 weeks ago

@puputskov aren’t those 2 the same thing but 2 different syntaxes? That’s how I learned.