If you start with the following single file:
//***************************************** //trivial.cpp --simple program in one file #include <iostream.h> //prototypes for user-defined function(s) float squared(float X); //the MAIN main ------------- void main() { cout << squared(2.50) << endl; return; } // user-defined function(s) --------- float squared(const float number) { return number * number; }
You can break it up into three separate files:
//****************************************** //split.cpp --simple program in three files #include <iostream.h> #include "squared.h" //the MAIN main ------------- void main() { cout << squared(2.50) << endl; return; }
//*************************************** //squared.h --prototypes for squared.cpp float squared(float X);
//***************************************** //squared.cpp --implementation of functions float squared(const float number) { return number * number; }