I have most of my classes split into two files (.h and .cpp). All of their methods (public, private or protected) are declared in the .h file and defined in the .cpp file.
However, sometimes I just need a quick helper method that is used by only one of the member methods. In these cases, is it possible to simply declare / define this method in the .cpp file as a non-member function without declaring it in the .h file?
What are the possible disadvantages of this approach? The one I see is that the definition of this method must precede its use in the .cpp file (if we do not want to use forward declaration). In addition, the IDE may have trouble finding these functions if they are completely in the .cpp file.
The reason I ask about this is because sometimes it seems like I am polluting the .h file with declarations of these methods that do not have access to the element data and are not used by any other class / file. It seems like I'm making really important declarations in the .h file, it's harder to find / read by entering these helper method declarations.
source
share