DEV Community

Discussion on: Is there a way to convert dynamically allocated memory to static memory OR copy ptr contents in C/C++?

 
pgradot profile image
Pierre Gradot

NOTE: this is juste a smiley: Oo => en.wikipedia.org/wiki/List_of_emot... => Surprised

1/2- Not everything is a matter a preference. See stackoverflow.com/questions/75191/...
3- Usually, we don't add this-> when its not needed. It improves codes' readability.*
4- OK
5- Both occur at the end of each iteration. In C++, we generally use ++i in for loops. See betterprogramming.pub/stop-using-i...
6- If you don't understand the C++ cast operators, then you don't understand what you code do. You should really use them. See stackoverflow.com/a/1609185/12342718
7- My bad: it works in the initialization list. Note that you have a cast that takes away the const.