Home > Refactorings > Refactorings for C++: moving methods to source file and back to the header

Refactorings for C++: moving methods to source file and back to the header

July 29th, 2011

There are two refactorings specific to the C++ language:

  • Move Method to Source File
  • Move Method to Header

The first one moves a method from a source file into the class declaration that is inside the header file. The second one moves the method’s implementation to a source file leaving the declaration in the header file. Having these refactorings makes it much easier to move method bodies between the header and source files.

Here are some simple samples:

Refactor! Move Method to Header refactoring

Result:

Refactor! Move Method to Header refactoring result

And vice versa:

Refactor! Move Method to Source File refactoring

 

—–
Products: Refactor! Pro, Refactor! for C++
Versions: 11.1 and up
VS IDEs: any
Updated: Jul/29/2011
ID: R033

Similar Posts: