I thought that was the purpose of header files? |
Common mistake for beginners.
Header files are for shared
declarations, not definitions.
What you have in your header file is a definition of the function.
Definitions should go in a .cpp file.
What I would suggest is that you create a TEDIOUS_MATH_FUNCTIONS.cpp file. Put the body (definition) of your shared functions there.
TEDIOUS_MATH_FUNCTIONS.h would still contain the declaration for areaofcircle() and any other functions that you write.
As I mentioned before, if you were to include TEDIOUS_MATH_FUNCTIONS.h (as it exists) in multiple compilation units, areaofcircle() would get compiled multiple times, thereby causing linker errors due to multiple occurrences of the function. The linker would not know which one to include in the generated executable.
BTW, the style of your code is good. It has proper indentation and is easy to read.
One error I do see is line 12 in main. You're using the assignment operator (=), not the equality operator (==). The loop will always execute as true.
Your
for
loops with a bool work, but seem unconventional.
while
seems more intuitive.