I have a simple header file and a cpp file. In the header I am declaring a class, and in the cpp file, defining it. Here is the header file
(RuntimeException.h)
exceptions.cpp:4: error: redefinition of ‘RuntimeException::RuntimeException(const std::string&)’
RuntimeException.h:13: error: ‘RuntimeException::RuntimeException(const std::string&)’ previously defined here
exceptions.cpp:7: error: ‘string’ in class ‘RuntimeException’ does not name a type
exceptions.cpp: In function ‘std::ostream& operator<<(std::ostream&, const RuntimeException&)’:
exceptions.cpp:11: error: redefinition of ‘std::ostream& operator<<(std::ostream&, const RuntimeException&)’
RuntimeException.h:17: error: ‘std::ostream& operator<<(std::ostream&, const RuntimeException&)’ previously defined here
I really cannot understand why the compiler thinks I am redefining when I think I am not.
After fixing this, I was still getting the same error. It seemed to have gone away after renaming the class to "myRuntimeException". Is there a pre-defined class called RuntimeException?
Thanks anyway, now on to other frustrating problems ! :-(