1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-23 23:03:40 +02:00

Exceptions do not take a string argument in their constructor.

This commit is contained in:
Adam
2015-06-01 21:57:18 -04:00
parent db11e29195
commit cea52ca434

View File

@@ -523,7 +523,7 @@ printMessage<10>(); // Prints "Learn C++ faster in only 10 minutes!"
// _catch_ handlers. // _catch_ handlers.
try { try {
// Do not allocate exceptions on the heap using _new_. // Do not allocate exceptions on the heap using _new_.
throw std::exception("A problem occurred"); throw std::exception();
} }
// Catch exceptions by const reference if they are objects // Catch exceptions by const reference if they are objects
catch (const std::exception& ex) catch (const std::exception& ex)
@@ -614,7 +614,7 @@ void doSomethingWithAFile(const char* filename)
{ {
FILE* fh = fopen(filename, "r"); // Open the file in read mode FILE* fh = fopen(filename, "r"); // Open the file in read mode
if (fh == nullptr) if (fh == nullptr)
throw std::exception("Could not open the file."); throw std::exception();
try { try {
doSomethingWithTheFile(fh); doSomethingWithTheFile(fh);