Not necessarily. A false negative bug in one copy of a test will remain even when fixed in a different copy.
We have a library that requires initialization, action, and then freeing of resources. Initialization involves creating and filling in a struct and/or passing parameter values to an initialization function. After that it is necessary to check for success/failure. That's for initializing the library. Then something similar is done to initialize an object we want to manipulate. I would begin with the copied code, replace the appropriate values in the initialization, replace the error handling, replace the action, and keep the freeing of resources as is.
1. Type out the new .h and cpp files from scratch.
2. Copy/rename the base class .h file, remove all non virtual functions and other text not needed for a derived class, copy/rename this new header creating a .cpp file, convert method declarations to definitions, and add method implementations.
3. Copy/renamed the .h and .cpp files for an existing derived class and replace the existing method implementations.
Option 3 is a reasonable choice and is an example of what article article discusses.
The example you provided is a good one, because it's an instance where you can't write abstractions to help you in the language you're using. Defining new classes, their interfaces and members is part of the necessary scaffolding when writing in C++. (Let's pretend it's not possible to do this with the C preprocessor.)
But the first example in the article does not sound like your example. Rather, it sounds closer to im3w1l's example, where the programmer copied code for some particular functionality, not for scaffolding.
But boilerplate code that interacts with an external library is not a primary activity in the language. You can hide it behind a class or a family of functions.
http://docs.nvidia.com/cuda/cublas/#example-code
edit: I guess if you write C++, you could protect the resources with RAII, and shave two lines of copy-pasted de-initialization.
That code does not initialize the library, instead the handle is stored as a global variable that is lazily initialized when using thrust methods. This makes it easier to use but has some drawbacks too. It can not use more than one card at once. It means every call will check if library is initialized safer but slower. Resources are not freed as soon as possible. A good trade off in the majority of cases.
A device vector is created and assigned a value in one call. Size is automatically tracked. Nice.
Errors are not handled. All code looks cleaner if you don't handle errors.
It sounds like it is the code review of future commits that needs to be fixed here.