If you are NOT using namespace std, it is a bit tricky:
//begin c++ file:
#include
int main()
{
throw std::logic_error("This is an error");
}
Tricky things to note:
1. We are NOT using the 'new' keyword here.
2. logic_error is in the std namespace... yet will not be recognized unless you #include
I find this weird because you don't need to #include
However, using namespace std is a bad idea because of all the names it imports into the global namespace.
I rather like to be more specific with which names/tokens I want to use in my code.
For example:
using std::string
So I don't have to write std::string everywhere.
No comments:
Post a Comment