Inherited source code is a fact of life for any professional programmer. Sometimes you inherit a 5000+ line C++ method chock full of pointers and pointers to pointers.
If you’re utilizing the copy-and-paste algorithm for refactoring large blocks of pointer and pointer-to-pointer riddled code then C++’s Pass by Reference support can make these changes much less painful. Thankfully it supports References to Pointers!
So instead of taking a block similar to the following:
and converting the loop into something unreadable, error prone and barely recognizable as the former loop body:
You can convert the loop into something easily recognizable as the former loop ala: