+ 1
how to create multiple files for cpp when not using classes
i m doing functional programming so i m not using classes. How can i have separate source file what to define in the header file and how. Example would be helpful
2 Answers
+ 3
You can use separate files for function prototypes and definitions. In the header file, you will have the prototype:
int timesTwo (int a);
And in the .cpp file you will have the definiton:
int timesTwo (int a) {
return 2 * a;
)
Of course then you will have to include the header file in main, as well as include the cpp file in the header file.