mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 23:33:00 +03:00
Exceptions do not take a string argument in their constructor.
This commit is contained in:
parent
db11e29195
commit
cea52ca434
@ -523,7 +523,7 @@ printMessage<10>(); // Prints "Learn C++ faster in only 10 minutes!"
|
||||
// _catch_ handlers.
|
||||
try {
|
||||
// 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 (const std::exception& ex)
|
||||
@ -614,7 +614,7 @@ void doSomethingWithAFile(const char* filename)
|
||||
{
|
||||
FILE* fh = fopen(filename, "r"); // Open the file in read mode
|
||||
if (fh == nullptr)
|
||||
throw std::exception("Could not open the file.");
|
||||
throw std::exception();
|
||||
|
||||
try {
|
||||
doSomethingWithTheFile(fh);
|
||||
|
Loading…
Reference in New Issue
Block a user