Hi I am working along with a beginner c++ book and I have gotten stuck on one part. The program is a calculator and it builds it throughout the book. Unfortunately where I'm stuck it doesn't have the code written out so I can't continue on.
This is where the problem is I will include the main.cpp too.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#ifndef ErrorHandlingModuleH
#define ErrorHandlingModuleH
#include <exception>
#include <iostream>
namespace SAMSErrorHandling
{
void Initialize(void);
int HandleNotANumberError(void);
int HandleRuntimeError(runtime_error);
}
#endif
I get an error saying that runtime_error not defined in scope in the .h file as well as the .cpp
and I get an error on the same lines saying SAMSErrorHandling::HandleRuntimeError is previously defined here....
In the text he says that "To use runtime_error, you need to change ErrorHandlingModule to #include <exception> (which I have done i believe) and add using namespace std wherever the exception is mentioned which I don't really understand where i write this or if this is the cause of the errors.
I just noticed something that's wrong in my code but doesn't seem to effect the errors I'm experiencing ....In line 72 of main.cpp I forgot to pass RunTimeError into HandleRuntimeError();
If you need to see PromptModule for any reason let me know and I will post it.
I have found out that the class runtime_error is in <stdexcept>
when I try to compile while including <stdexcept> I get an undefined reference to winmain@16 and im am compiling a console app from the command line manually. why would this happen??? Do I definetly have acces to stdexcept library would this occur if I didnt?
I had this error before a few chapters earlier and I can't remember how I got it to work
You are probably compiled the application as a Windows app, hence why it is looking for WinMain. Try looking for a switch or option somewhere to compile as a console app.